user458295 user458295 - 9 days ago 6
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

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): http://code.google.com/p/backport-android-bluetooth/