List of usage examples for android.bluetooth BluetoothAdapter getRemoteDevice
public BluetoothDevice getRemoteDevice(byte[] address)
From source file:com.evothings.BLE.java
private void connect(final CordovaArgs args, final CallbackContext callbackContext) { final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); checkPowerState(adapter, callbackContext, new Runnable() { @Override/*from w w w . jav a2 s.co m*/ public void run() { try { // Each device connection has a GattHandler, which handles the events the can happen to the connection. // The implementation of the GattHandler class is found at the end of this file. GattHandler gh = new GattHandler(mNextGattHandle, callbackContext); gh.mGatt = adapter.getRemoteDevice(args.getString(0)).connectGatt(mContext, true, gh); // Note that gh.mGatt and this.mGatt are different object and have different types. if (mGatt == null) mGatt = new HashMap<Integer, GattHandler>(); Object res = mGatt.put(mNextGattHandle, gh); assert (res == null); mNextGattHandle++; } catch (Exception e) { e.printStackTrace(); callbackContext.error(e.toString()); } } }); }