Possible Duplicate:
How to enable/disable bluetooth programmatically in android
I'm a newbie in android development. I'm not able to disable Bluetooth in my app. Here I've used a checkbox.Enabling of which enables the bluetooth but while disabling it remains enable.. What do I do?
My code:
enable_chkbox=(CheckBox)findViewById(R.id.chkboxenable);
enable_chkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(buttonView.isChecked())
{
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
else if(!buttonView.isChecked())//updated
{
mBluetoothAdapter.disable();
//finish();
}
}
}
});
Android Manifest file permissions:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>