Reputation:
I want to know how can I ask permission from the user to change the state of the bluetooth? I don't need for wifi because it's not mandatory.
I search the basic window where the user check the Yes or No buttons for allow app to modify the state of app.
Upvotes: 1
Views: 4009
Reputation: 364
This code will generate a popup which requests the user for permission to turn on Bluetooth. "300" is the discoverable duration to enable discovering option.
Intent discoverableIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
Follow this Bluetooth Documentation for more on Bluetooth activity.
Upvotes: 1