android - Avoid user dialog when bonding with BLE device using PIN on latest API (Lollipop) -


i bonding/pairing bluetooth low energy device android app. when bonding initiated, "enter pin"-dialog shown. automatically disappears when set pin code. dialog appears , disappears slow enough confuse , annoy user. how can avoid dialog?

i found nothing on bonding in android ble guide https://developer.android.com/guide/topics/connectivity/bluetooth-le.html

i helped other question, solution not remove dialog. how can avoid or dismiss android's bluetooth pairing notification when doing programmatic pairing?

this question suggests removing reciever in sdk. android prevent bluetooth pairing dialog

is there no way solve within api? question on subject few years old , there has been lot of changes in android bluetooth api recently. using api 19 (4.4 kitkat) use api 22 (5.1 lollipop) if help.

this how bonding:

mybluetoothdevice.createbond(); 

i listen pairing intent able provide pin @ right moment. listen bonding intent.

//register before calling createbond context.registerreceiver(broadcastreceiver, new intentfilter(bluetoothdevice.action_bond_state_changed)); context.registerreceiver(broadcastreceiver, new intentfilter(bluetoothdevice.action_pairing_request));  //the recievers final broadcastreceiver broadcastreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) {     string action = intent.getaction();              if (bluetoothdevice.action_pairing_request.equals(action))     {     bluetoothdevice device = intent.getparcelableextra(bluetoothdevice.extra_device);         byte[] pin = convertpintobytes("111111"); //convertpintobytes reason not available in api, made copy         device.setpin(pin);     }      if (bluetoothdevice.action_bond_state_changed.equals(action)) {         if (bluetoothdevice.bond_bonded == device.getbondstate())         {             //success!         }     } } 


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -