Mick D
Mick D

Reputation: 172

Custom Bluetooth message mBluetoothAdapter

With the following code you can pop up a window with bluetooth acces request:

if (!mBluetoothAdapter.isEnabled()) {
    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}

The output of the code is the following image:

enter image description here

Is it possible to change the message (so not "An app wants to turn on Bluetooth", but something like "Hey can you please turn on Bluetooth?"

Upvotes: 1

Views: 1797

Answers (2)

Massimo Milazzo
Massimo Milazzo

Reputation: 3532

You should create your own dialog with your own message and then call

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.enable();

And do not forget to declare the BLUETOOTH_ADMIN permission in your manifest.

Anyway, this operation is discouraged... The enable() method is provided only for applications that include a user interface for changing system settings, such as a "power manager" app.

Upvotes: 5

JPS
JPS

Reputation: 624

No, this is build-in Android functionality, so you would have to make a custom dialog which asks the question the way you want.

Then you would enable or disable Bluetooth programmatically based on what the users choice was.

Upvotes: 1

Related Questions