How to fix Android BLE SCAN_FAILED_APPLICATION_REGISTRATION_FAILED error?

前端 未结 5 2006
北荒
北荒 2021-02-07 03:28

Most of times it works great but sometimes i\'m having this error while trying to discover BLE devices:

02-12 18:00:41.952  16178-16339/com.icrealtime.allie W/Bl         


        
5条回答
  •  长情又很酷
    2021-02-07 04:16

    A possible workaround it might be to disable/enable the blueetooth programmatically. When you got the error SCAN_FAILED_APPLICATION_REGISTRATION_FAILED you should disable the BluetoothAdapter:

    BluetoothAdapter.getDefaultAdapter().disable();
    

    Disabling BluetoothAdapter, the event STATE_TURNING_OFF is fired. Once this event is fired, try to reconnect to the BluetoothAdapter:

    case BluetoothAdapter.STATE_OFF:
      Log.d(TAG, "bluetooth adapter turned off");
      handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "bluetooth adapter try to enable");
            BluetoothAdapter.getDefaultAdapter().enable();
        }}, 500);
      break;
    

提交回复
热议问题