多年来,我一直在我的应用程序中激活蓝牙,执行以下简单代码:
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
if (btAdapter.isEnabled() == false)
btAdapter.enable() 但现在,在Android 9中,系统会向用户显示一个屏幕,上面写着“应用程序xxx正在尝试启用蓝牙。你想允许它吗?”(或类似的东西)。这对我的应用程序功能非常恼人,因为它在后台自动工作,所以不需要用户迭代。有没有办法在没有用户交互的情况下在Android 9中激活蓝牙?
发布于 2019-04-06 17:39:42
这是可以做到的,但您需要给特定的应用程序写系统设置的权限。
请参阅我在XDA论坛上的帖子:https://forum.xda-developers.com/mate-9-pro/help/allow-to-enable-bluetooth-off-user-t3918723
https://stackoverflow.com/questions/54172456
复制相似问题