蓝牙连接,如可穿戴设备。
代码示例:
// 创建蓝牙服务 BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
// 开始扫描 bluetoothAdapter.startLeScan(mLeScanCallback);
// 定义回调接口 private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { // 处理发现的设备 } };