最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - RemoveBound bluetooth device - Stack Overflow

programmeradmin2浏览0评论

I m building an Android application with Kotlin. With this application I can pairing bluetooth device. I need also to remove pairing by passing MacAddress of device. So I write the following code to remove pair with device:

pairedDevices = mBluetoothAdapter?.bondedDevices;    
if (pairedDevices?.size!! > 0) {
    for (device in pairedDevices!!) {
        if(device.address.equals(d.macAddress)){
            try {

                val m: Method = device.javaClass
                    .getMethod("removeBond")
                m.invoke(device, null as Array<Any?>?)
            } catch (e: Exception) {
                e.message?.let { Log.e("Removing has been failed.", it) }
            }
        }

    }
}

The method is executed but after that if I try to go in bluetooth settings, the device that I removed with that method is still associated

edit

The error that I received is this:

Wrong number of arguments; expected 0, got 1
发布评论

评论列表(0)

  1. 暂无评论