Yes, fetchUuidsWithSdp () is a good idea because, unlike getUuids (), it makes the device try to connect to the target device and update its information about it.
The official support for fetchUuidsWithSdp was just added in 4.0.3, but it was available before that using reflection.
public static void startFetch( BluetoothDevice device ) { // Need to use reflection prior to API 15 Class cl = null; try { cl = Class.forName("android.bluetooth.BluetoothDevice"); } catch( ClassNotFoundException exc ) { Log.e(CTAG, "android.bluetooth.BluetoothDevice not found." ); } if (null != cl) { Class[] param = {}; Method method = null; try { method = cl.getMethod("fetchUuidsWithSdp", param); } catch( NoSuchMethodException exc ) { Log.e(CTAG, "fetchUuidsWithSdp not found." ); } if (null != method) { Object[] args = {}; try { method.invoke(device, args); } catch (Exception exc) { Log.e(CTAG, "Failed to invoke fetchUuidsWithSdp method." ); } } } }
Usually, the android.bluetooth.device.action.UUID file is usually registered, but you may want to register instead to change the name.
Please note that if you decide to register for the UUID action, it was written with an error before API 15 as "android.bleutooth.device.action.UUID" (e and u in bluetooth are replaced).
source share