考虑:
fun BluetoothDevice.removeBond() {
try {
javaClass.getMethod("removeBond").invoke(this)
} catch (e: Exception) {
Timber.i("Removing bond has been failed. ${e.message}")
} }
在另一部 Android 手机中,此方法运行良好,但不适用于Redmi手机。
日志
1610017762.258 ? I/BluetoothDevice: removeBond() for device #### 由 pid: 2027 tid: 2027 调用
1610017762.268 ? E/BluetoothUtils: checkCallerAllowedToTouchBondDevices: BT设备挂在1000上,10211不能碰
1610017762.268 ? W/BluetoothAdapterService:removeBond() - 不允许 ownerUid 删除绑定,除非 callerUid 是系统 uid。