1.申请权限
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2.代码
//得到蓝牙配对的设备列表 public void removePairDevice(){ BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if(mBluetoothAdapter != null){ Set<BluetoothDevice> bondedDevices = mBluetoothAdapter.getBondedDevices(); for(BluetoothDevice device : bondedDevices ){ unpairDevice(device); } } } //通过反射来调用BluetoothDevice.removeBond取消设备的配对 private void unpairDevice(BluetoothDevice device) { try { Method m = device.getClass().getMethod("removeBond", (Class[]) null); m.setAccessible(true); m.invoke(device, (Object[]) null); } catch (Exception e) { Log.e("ble",e.toString()); } }