android - code for scanning ble4.0 with HMsoft10 in nexus 5 -
i trying connect ble4.0 hmsoft-10 it's working times it's not work in nexus 5 this? please replay fast advance thanks. thanking you...!
my code
private void scanledevice() { new thread() {
@override public void run() { mbluetoothadapter.startlescan(mlescancallback); try { thread.sleep(scan_period); } catch (interruptedexception e) { e.printstacktrace(); } mbluetoothadapter.stoplescan(mlescancallback); } }.start(); } private bluetoothadapter.lescancallback mlescancallback = new bluetoothadapter.lescancallback() { @override public void onlescan(final bluetoothdevice device, final int rssi, byte[] scanrecord) { runonuithread(new runnable() { @override public void run() { if (device != null) { if (mdevices.indexof(device) == -1) mdevices.add(device); } } }); } };
see happens if handle startscan()
, stopscan()
commands on uithread. better make delay until stopscan()
handler , postdelayed runnable, in this codesample. question connection problems, scanning devices?
Comments
Post a Comment