user458295 user458295 - 1 year ago 105
Android Question

How to enable/disable bluetooth programmatically in android

HI all,

I want to enable/disable bluetooth through the program..I has the following code.

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);

But this sort of code is not working in SDK 1.5..How can i do the same in SDK 1.5.?

Answer Source

Android BluetoothAdapter docs say it has been available since API Level 5. API Level 5 is Android 2.0.

You can try using a backport of the Bluetooth API (have not tried it personally):

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download