简体   繁体   中英

Turn on Bluetooth without notifying user - Android phone

Is there any way to turn on Bluetooth without notifying user?

I m aware about android Bluetooth working, it notifies user whenever Bluetooth on as toast " Bluetooth turned on " im able to turn on Bluetooth by the help of code, But i do not want it to show notification " Bluetooth turned on "

Something like this:

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    
if (mBluetoothAdaper != null) {
    mBluetoothAdapter.enable(); 
} 

don't forget permissions:

android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN

edit: if you just don't want the message to appear, just delete:

Toast.maketext(context, "Bluetooth turned on", Toast.LENGHT.SHORT).show();

somewhere in your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM