How to enable/disable bluetooth programmatically in android
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/
Turn device bluetooth on or off
Firstly you need to add these permissions
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
and to Enable/Disable Bluetooth programmatically use BluetoothAdapter
for example:
btnBluetooth.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter.isEnabled()){
adapter.disable();
} else {
adapter.enable();
}
} });
For more information check Bluetooth Docs
Enable Disable Bluetooth in Android
You might want to read the Android documentation to find the answer yourself:
http://developer.android.com/guide/topics/wireless/bluetooth.html
Related Topics
How to Set Background Color of a View
How to Display Inline Images from HTML in an Android Textview
Asynctask VS Thread in Android
How to Startforeground() Without Showing Notification
How to Call a .Net Webservice from Android Using Ksoap2
Android Turn On/Off Wifi Hotspot Programmatically
How to Create a File in Android
Huawei, Logcat Not Showing the Log for My App
How to Change the Android Actionbar Title and Icon
Adb' Is Not Recognized as an Internal or External Command, Operable Program or Batch File
Android- Create JSON Array and JSON Object
Android Asynctask Threads Limits
Retrieve Incoming Call's Phone Number in Android
How to Create a Circular Progressbar in Android Which Rotates on It
How to Detect Shake Event with Android
In Android, How to Set Margins in Dp Programmatically
How to Increase Storage for Android Emulator? (Install_Failed_Insufficient_Storage)