android解除蓝牙的方法,如何在Android上以编程方式取消配对或删除配对的蓝牙设备?...
这段代码对我有用private void pairDevice(BluetoothDevice device) {try {if (D)Log.d(TAG, "Start Pairing...");waitingForBonding = true;Method m = device.getClass().getMethod("createBond", (Class[]) null);m.invok
这段代码对我有用
private void pairDevice(BluetoothDevice device) {
try {
if (D)
Log.d(TAG, "Start Pairing...");
waitingForBonding = true;
Method m = device.getClass()
.getMethod("createBond", (Class[]) null);
m.invoke(device, (Object[]) null);
if (D)
Log.d(TAG, "Pairing finished.");
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
private void unpairDevice(BluetoothDevice device) {
try {
Method m = device.getClass()
.getMethod("removeBond", (Class[]) null);
m.invoke(device, (Object[]) null);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
更多推荐
所有评论(0)