我想等我的设备完全配对(BLE)

时间:2019-06-19 11:08:02

标签: java android bluetooth bluetooth-lowenergy

我正在研究 BLE 上的内容,但为了配对,我想在同一活动中等待

2 个答案:

答案 0 :(得分:0)

在您的应用中。注册广播接收器以进行蓝牙配对

        val filter = IntentFilter()
        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED)
        filter.addAction(BluetoothDevice.ACTION_FOUND)
        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED)
        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)
        filter.priority = IntentFilter.SYSTEM_HIGH_PRIORITY
        registerReceiver(mReceiver, filter)

在接收器内部进行操作

 mReceiver = object : BroadcastReceiver() {
            override fun onReceive(context: Context, intent: Intent) {
   //Do your Stuff
  }
}

答案 1 :(得分:0)

谢谢。 我已经用这个

getimagesize