Reputation: 466
How can I switch on and off bluetooth directly without needing to have a pop up asking user consent. I tried btAdapter.enable() but this did not work for me.
Upvotes: 1
Views: 336
Reputation: 717
String status;
if (bluetooth.isEnabled()) {
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
status = mydevicename + ” : ” + mydeviceaddress;
}
else
{
status = “Bluetooth is not Enabled.”;
}
Toast.makeText(this, status, Toast.LENGTH_LONG).show();
Do on or off now ur wish :)
Upvotes: 1
Reputation: 6954
if (!mBluetoothAdapter.isEnabled()) {
//do some thing here
}else{
//do some thing here
}
Upvotes: 0
Reputation: 46
As far as I know, you'd need to add it to the permissions xml (AndroidManifest.xml) file to not have user intervention.
http://www.brighthub.com/mobile/google-android/articles/103281.aspx
Upvotes: 2