I am having trouble with calling my onLeScan. I placed a tag in my start scan and that gets called every time. For some reason my onLeScan never is getting called. Does anyone see an issue with what I have done? onLeScan should be called right after startLeScan, correct?
private void startScan() {
Log.i(TAG, "Starting Scan");
mBluetoothAdapter.startLeScan(this);
setProgressBarIndeterminateVisibility(true);
mHandler.postDelayed(mStopRunnable, 5000);
}
@Override
public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) {
Log.i(TAG, "IN OnLeScan");
Log.i(TAG, "New LE Device: " + device.getName() + " @ " + rssi);
runOnUiThread(new Runnable() {
@Override
public void run(){
DeviceBeacon beacon = new DeviceBeacon(device.getName(), device.getAddress(), rssi);
mHandler.sendMessage(Message.obtain(null, 0, beacon));
}
});
}
EDIT Changed up my onLeScan function. Still not working but I think I am going toward the right path. DeviceBeacon is a class that just includes methods: getName(), getSignal(), and getAddress()
EDIT 2 I not sure where my error is. I have 2 nexus 7's I have both the bluetooth and bluetooth_admin permissions set along with the extra line to make sure I am only searching for bluetoothLE devices. startLeScan returns true. It is just not finding any devices in the area. Any reason why this may be? I even have both devices visibility set to true.
EDIT 3 Git repo if you want to look at some of the code. https://github.com/cshunger/AndroidBluetoothTouch
EDIT 4 My log cat:
01-12 01:18:59.728: I/BluetoothTouch(14510): Starting Scan
01-12 01:18:59.728: D/BluetoothAdapter(14510): startLeScan(): null
01-12 01:18:59.738: D/BluetoothAdapter(14510): onClientRegistered() - status=0 clientIf=5
01-12 01:19:04.763: I/BluetoothTouch(14510): Stoping Scan
01-12 01:19:04.763: D/BluetoothAdapter(14510): stopLeScan()