/** * Creates a new disconnect request. This allows to set a callback to a disconnect event, * just like any other request. * * @return The new disconnect request. */ @NonNull static DisconnectRequest disconnect() { return new DisconnectRequest(Type.DISCONNECT); }
@Override public void onBackPressed() { mBleManager.disconnect().enqueue(); super.onBackPressed(); }
/** * Disconnects from the device or cancels the pending connection attempt. * Does nothing if device was not connected. * * @return The disconnect request. The completion callback will be called after the device * has disconnected and the connection was closed. If the device was not connected, * the completion callback will be called immediately with device parameter set to null. */ @NonNull public final DisconnectRequest disconnect() { return Request.disconnect().setManager(this); }
/** * Disconnects the given device and removes the associated BleManager object. * If the list of BleManagers is empty while the last activity unbinds from the service, * the service will stop itself. * @param device target device to disconnect and forget */ public void disconnect(final BluetoothDevice device) { final BleManager<BleManagerCallbacks> manager = mBleManagers.get(device); if (manager != null && manager.isConnected()) { manager.disconnect().enqueue(); } mManagedDevices.remove(device); }
@Override public void onBackPressed() { mBleManager.disconnect().enqueue(); super.onBackPressed(); }
/** * Disconnects from the sensor. */ public final void disconnect() { final int state = mBleManager.getConnectionState(); if (state == BluetoothGatt.STATE_DISCONNECTED || state == BluetoothGatt.STATE_DISCONNECTING) { mBleManager.close(); onDeviceDisconnected(mBluetoothDevice); return; } mBleManager.disconnect().enqueue(); }
/** * Called when user press CONNECT or DISCONNECT button. See layout files -> onClick attribute. */ public void onConnectClicked(final View view) { if (isBLEEnabled()) { if (!mDeviceConnected) { setDefaultUI(); showDeviceScanningDialog(getFilterUUID()); } else { mBleManager.disconnect().enqueue(); } } else { showBLEDialog(); } }
/** * Called when user press CONNECT or DISCONNECT button. See layout files -> onClick attribute. */ public void onConnectClicked(final View view) { if (isBLEEnabled()) { if (!mDeviceConnected) { setDefaultUI(); showDeviceScanningDialog(getFilterUUID()); } else { mBleManager.disconnect().enqueue(); } } else { showBLEDialog(); } }