how to DISABLE bluetooth on the Onclick of a button?
public void btd(View view) {
BluetoothAdapter blue = BluetoothAdapter.getDefaultAdapter();
blue.disable();
}
OR
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}else{
if (!mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.enable();
}else{
mBluetoothAdapter.disable();
}
}
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
the code only works if i enable bluetooth vis code, but if its enable via notificationbar, then the app gets force closed!!
Here is error Log http://justpaste.it/fd7t