user6842260
user6842260

Reputation:

Android : Ask permission for bluetooth

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

Answers (1)

Raviraj Subramanian
Raviraj Subramanian

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

Related Questions