简体   繁体   English

Android,设置蓝​​牙和GPS,具有设备所有者权限

[英]Android, set Bluetooth and GPS on, with Device Owner permission

In my application i got the Device Owner permissions, set through Adb shell . 在我的应用程序中,我获得了设备所有者权限,通过Adb shell设置

Now I'm able to create a kios mode enviroment which allow the user to interact only with my app. 现在我可以创建一个kios模式环境,允许用户只与我的应用程序进行交互。

Next step, I'd like to programmatically turn on the Bluetooth and Location services without asking for any permissions. 下一步,我想以编程方式打开蓝牙和位置服务,而无需任何权限。

In the Blutooth case I only need to get through the "Would you like to turn on bluetooth?" 在Blutooth案例中,我只需要通过“你想打开蓝牙吗?” message, while with location is a bit more complicated. 消息,而位置有点复杂。

Location to works requires the system permission, and then requires the user to turn it on. 工作位置需要系统权限,然后要求用户打开它。

How can I directly turn them on now that my App is in Device Owner Mode? 现在我的应用程序处于设备所有者模式时,如何直接打开它们?

Thanks. 谢谢。

You can use the following command for enabling gps : 您可以使用以下命令启用gps:

DevicePolicyManagerdpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
dpm.setSecureSetting(mDeviceAdmin, Settings.Secure.LOCATION_MODE, String.valueOf(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY));

and the following for bluetooth 以及蓝牙的以下内容

dpm.setSecureSetting(mDeviceAdmin, Settings.Secure.BLUETOOTH_ON, String.valueOf(1));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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