In Android 2.1, to unpair a Bluetooth device you can go to Bluetooth settings, long-click on a device and select Unpair to unpair that device. I want to be able to do this f
Another way:
public void clear(View v) {
Set bondedDevices = adapter.getBondedDevices();
try {
Class> btDeviceInstance = Class.forName(BluetoothDevice.class.getCanonicalName());
Method removeBondMethod = btDeviceInstance.getMethod("removeBond");
String currentMac = getCurrentMAC();
boolean cleared = false;
for (BluetoothDevice bluetoothDevice : bondedDevices) {
String mac = bluetoothDevice.getAddress();
if(mac.equals(currentMac)) {
removeBondMethod.invoke(bluetoothDevice);
Log.i(TAG,"Cleared Pairing");
cleared = true;
break;
}
}
if(!cleared) {
Log.i(TAG,"Not Paired");
}
} catch (Throwable th) {
Log.e(TAG, "Error pairing", th);
}
}