If an Android app wants to access bluetooth, does it have to explicitly ask the user to switch bluetooth on? Could the user authorise the app to switch it on (and off) whenever it wants?
2
- i don't know if you can do something like that, but i think if you can maybe it's will be security issue.NoXSaeeD– NoXSaeeD2014-05-27 10:12:15 +00:00Commented May 27, 2014 at 10:12
- Usually you've got to resonse to answers and commentsVilen– Vilen2014-05-29 21:15:37 +00:00Commented May 29, 2014 at 21:15
Add a comment |
1 Answer
NO need to ask switch it you manually, you can just ask for permission also you need to add permissions in android manifest
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" /> code for enabling BT
// enable device discovery - this will automatically enable Bluetooth Intent discoveryIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoveryIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, DISCOVER_DURATION); startActivityForResult(discoveryIntent, REQUEST_BLU); 2 Comments
Zar E Ahmer
And what is the way to disable bluetooth. your code enable bluetooth as commented by you.
Vilen
I guess following code should disable it BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter.isEnabled()){ mBluetoothAdapter.disable(); }