在不通知用户的情况下打开蓝牙 - Android phone

Turn on Bluetooth without notifying user - Android phone

有什么方法可以在不通知用户的情况下打开蓝牙吗?

我知道 android 蓝牙正在工作,它会在蓝牙打开时通知用户作为吐司“蓝牙已打开”我能够在以下帮助下打开蓝牙代码,但我不希望它显示通知“蓝牙已打开

像这样:

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

不要忘记权限:

android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN

编辑: 如果您只是不想显示消息,只需删除:

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

代码中的某处。