Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if bluetooth is enabled programmatically?

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 ways to do it?

like image 812
Zerhinne Avatar asked Oct 06 '11 09:10

Zerhinne


People also ask

How do you check Bluetooth is enabled or not?

Call isEnabled() to check whether Bluetooth is currently enabled. If this method returns false, then Bluetooth is disabled. To request that Bluetooth be enabled, call startActivityForResult() , passing in an ACTION_REQUEST_ENABLE intent action.

Is Bluetooth enabled Android?

The Android platform includes support for the Bluetooth network stack, which allows a device to wirelessly exchange data with other Bluetooth devices. The app framework provides access to the Bluetooth functionality through Bluetooth APIs.


1 Answers

There you go:

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) {     // Device does not support Bluetooth } else if (!mBluetoothAdapter.isEnabled()) {     // Bluetooth is not enabled :) } else {     // Bluetooth is enabled  } 

With uses-permission

 <uses-permission android:name="android.permission.BLUETOOTH" android:required="false" /> 
like image 145
Pete Houston Avatar answered Oct 02 '22 18:10

Pete Houston