How to check if bluetooth is enabled programmatically?

后端 未结 6 1109
小蘑菇
小蘑菇 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-13 23:59

    public boolean isBluetoothEnabled()
        {
            BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
            return mBluetoothAdapter.isEnabled();
    
        }
    

    with the permission in manifest file:

    
    

提交回复
热议问题