How to check if bluetooth is enabled programmatically?

后端 未结 6 1115
小蘑菇
小蘑菇 2020-12-13 23:46

I would like to check if bluetooth is enabled on any Android device periodically. Is there any intents that I could catch using BroadcastReceiver to do so, or is there other

6条回答
  •  孤城傲影
    2020-12-14 00:23

    This is how I did it with the help of @xjaphx's answer, slightly simplified version:

     private boolean getBlueToothOn(){
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); 
          return btAdapter != null && btAdapter.isEnabled();
        }
    
     
    

提交回复
热议问题