Here's my code for scanner callback.
private BluetoothAdapter.LeScanCallback mLeScanCallback =
new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (device == null) {
return;
}
if (!device.getName().startsWith("DEVICE_NAME")) {
System.out.println("Did not start with DEVICE_NAME, removing: " + device.getName());
return;
}
if (!devices.contains(device)) {
System.out.println("Valid DEVICE_NAME Adding: " + device.getName());
devices.add(device);
}
}
});
}
};
I am getting a null BluetoothDevice
object when I scan within certain geographic locations. For instance, it works perfectly fine within my home or place of work.
However, if I take my hardware + phone to the airport or big Marriott hotels then it messes up and returns me a null BluetoothDevice
.
What does a null device mean, how can I go about fixing this?
Any advice would be appreciated.
Regards