List of usage examples for android.bluetooth BluetoothGatt getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) static boolean refreshDeviceCache(BluetoothGatt gatt) { try {/*from w w w. j av a 2 s . c om*/ Method localMethod = gatt.getClass().getMethod("refresh", new Class[0]); if (localMethod != null) { return (boolean) (Boolean) localMethod.invoke(gatt, new Object[0]); } } catch (Exception ignored) { } return false; }
From source file:com.elitise.appv2.Peripheral.java
private boolean refreshDeviceCache(BluetoothGatt gatt) { try {//from ww w . j a v a2 s . c o m BluetoothGatt localBluetoothGatt = gatt; Method localMethod = localBluetoothGatt.getClass().getMethod("refresh", new Class[0]); if (localMethod != null) { boolean bool = ((Boolean) localMethod.invoke(localBluetoothGatt, new Object[0])).booleanValue(); return bool; } } catch (Exception localException) { Log.e(TAG, "An exception occured while refreshing device"); } return false; }
From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuService.java
/** * Clears the device cache. After uploading new firmware the DFU target will have other services than before. * /* w ww .ja v a 2 s .c o m*/ * @param gatt * the GATT device to be refreshed */ private void refreshDeviceCache(final BluetoothGatt gatt) { /* * There is a refresh() method in BluetoothGatt class but for now it's hidden. We will call it using reflections. */ try { final Method refresh = gatt.getClass().getMethod("refresh"); if (refresh != null) { final boolean success = (Boolean) refresh.invoke(gatt); logi("Refreshing result: " + success); } } catch (Exception e) { loge("An exception occured while refreshing device", e); } }
From source file:br.liveo.ndrawer.ui.activity.MainActivity.java
License:asdf
public boolean refreshDeviceCache(BluetoothGatt gatt) { try {/* w ww . ja v a 2s. c o m*/ BluetoothGatt localBluetoothGatt = gatt; Method localMethod = localBluetoothGatt.getClass().getMethod("refresh", new Class[0]); if (localMethod != null) { boolean bool = ((Boolean) localMethod.invoke(localBluetoothGatt, new Object[0])).booleanValue(); return bool; } } catch (Exception localException) { Log.e("BluetoothLeService : ", "An exception occured while refreshing device"); } return false; }
From source file:com.lef.ibeacon.service.UpdateService.java
/** * Clears the device cache.// w ww .j a v a2 s . c om * <p> * CAUTION:<br /> * It is very unsafe to call the refresh() method. First of all it's hidden * so it may be removed in the future release of Android. We do it because * Nordic Beacon may advertise as a beacon, as Beacon Config or DFU. Android * does not clear cache then device is disconnected unless manually * restarted Bluetooth Adapter. To do this in the code we need to call * {@link BluetoothGatt#refresh()} method. However is may cause a lot of * troubles. Ideally it should be called before connection attempt but we * get 'gatt' object by calling connectGatt method so when the connection * already has been started. Calling refresh() afterwards causes errors 129 * and 133 to pop up from time to time when refresh takes place actually * during service discovery. It seems to be asynchronous method. Therefore * we are refreshing the device after disconnecting from it, before closing * gatt. Sometimes you may obtain services from cache, not the actual values * so reconnection is required. * * @param gatt * the Bluetooth GATT object to refresh. */ private boolean refreshDeviceCache(final BluetoothGatt gatt) { /* * There is a refresh() method in BluetoothGatt class but for now it's * hidden. We will call it using reflections. */ try { final Method refresh = gatt.getClass().getMethod("refresh"); if (refresh != null) { return (Boolean) refresh.invoke(gatt); } } catch (final Exception e) { loge("An exception occured while refreshing device"); } return false; }