Enable Disable Bluetooth in Android

0 votes
asked Sep 19, 2010 by sri-sri

I want to enable and disable bluetooth in android programmatically..Please help me how to do this..Thanks in advance.

3 Answers

0 votes
answered by bhagat

You can directly open Bluetooth by calling function turnOn() on click of button(on):

void turnOn()
    if (bluetoothAdapter == null)
        status.setText("BlueTooth adapter not found");
    else if (bluetoothAdapter.isEnabled())
        Toast.makeText(MainActivity.this, "Bluetooth is already on.", Toast.LENGTH_SHORT).show();
0 votes
answered Sep 19, 2010 by krtek

You might want to read the Android documentation to find the answer yourself: http://developer.android.com/guide/topics/wireless/bluetooth.html

0 votes
answered Sep 9, 2013 by jpm

I know this has been answered but just in case someone else wants this info. There are two ways to enable bluetooth one is to use the Intents and send a user request

Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
activity.startActivityForResult(enableIntent, someIntegerValue);

second is to just call the enable method on the adapter, only use this method if user input is not needed or wanted.

BluetoothAdapter blue = BluetoothAdapter.getDefaultAdapter();
if (!blue.isEnabled())

to disable you just call disable method on adapter.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter