java - Android Bluetooth Service discovery yields different results on two different devices - is it Android Version? -
running code below, galaxy tablet (sch-i905 - android 4.0.4) correctly discovers 3 bluetooth services on pc. running same code on galaxy nexus - android 4.2.2) finds 1 of services. ideas appreciated:
private final broadcastreceiver servicereceiver = new broadcastreceiver() { public void onreceive(context context, intent intent) { string action = intent.getaction(); if ( bluetoothdevice.action_uuid.equals(action) ) { bluetoothdevice device = intent.getparcelableextra("android.bluetooth.device.extra.device"); parcelable[] uuidextra = intent.getparcelablearrayextra("android.bluetooth.device.extra.uuid"); for( int = 0; < uuidextra.length; i++ ) { toast.maketext( this, device.getname() + ": " + uuidextra[i].tostring(), toast.length_long).show(); } } } };
in eclipse debugger, following array shows 3 occurrences [00001000-0000-1000-8000-00805f9b34fb, 00001115-0000-1000-8000-00805f9b34fb, 00001202-0000-1000-8000-00805f9b34fb] tablet, [00001115-0000-1000-8000-00805f9b34fb] nexus. don't know if it's version or hardware issue. thank you, john
one last note - using... bluetoothdevice device = intent.getparcelableextra(bluetoothdevice.extra_device); device.fetchuuidswithsdp();
john
this seems android version issue. had same results using htc desire (android 2.3) worked similar code yours , lenovo tablet (android 4.2.2) wont connect no matter do. reading million posts here have discovered far:
1) make sure cancel discovery on adapter before try connect 2) try using reflection, people claim worked them 3) try this
method m = device.getclass().getmethod("createinsecurerfcommsocket", new class[] {int.class}); socket = (bluetoothsocket) m.invoke(device, 1); bluetoothadapter.canceldiscovery(); socket.connect();
Comments
Post a Comment