【问题标题】:Android, set Bluetooth and GPS on, with Device Owner permission安卓,开启蓝牙和GPS,有设备所有者权限
【发布时间】:2017-05-03 08:16:32
【问题描述】:

在我的应用程序中,我获得了设备所有者权限,通过 Adb shell 设置

现在我可以创建一个 kios 模式环境,允许用户仅与我的应用交互。

下一步,我想在不请求任何权限的情况下以编程方式打开蓝牙和定位服务。

在蓝牙的情况下,我只需要通过“你想打开蓝牙吗?”消息,而位置信息则稍微复杂一些。

工作地点需要系统权限,然后需要用户开启。

既然我的应用处于设备所有者模式,我该如何直接开启它们?

谢谢。

【问题讨论】:

    标签: android bluetooth gps device-owner


    【解决方案1】:

    您可以使用以下命令启用 gps:

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

    以下是蓝牙

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多