在Android 9 Pie中激活蓝牙

问题描述 投票:0回答:1

我多年来一直在我的应用程序中激活蓝牙做这个简单的代码:

BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
if (btAdapter.isEnabled() == false) 
   btAdapter.enable() 

但是现在,使用Android 9,系统会向用户显示一个屏幕,其中包含“应用程序xxx正在尝试启用蓝牙。您要允许它吗?” (或类似的东西)。这对我的应用功能非常烦人,因为它在后台自动运行,因此不需要用户迭代。有没有办法在没有用户交互的情况下在Android 9中激活蓝牙?

android bluetooth android-9.0-pie
1个回答
1
投票

可以这样做,但您需要授予特定应用程序编写系统设置的权限。

请参阅我在XDA论坛上的帖子:https://forum.xda-developers.com/mate-9-pro/help/allow-to-enable-bluetooth-off-user-t3918723

© www.soinside.com 2019 - 2024. All rights reserved.