Toggle gps on root devices on Android

后端 未结 3 2078
不知归路
不知归路 2020-12-06 20:03

Starting with some Android version (I think 2.3.x), you cannot turn on/off the GPS via the API, no matter what permissions the app has. In the past, it was possible by explo

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 20:29

    NO Need system app just use su for enabling gps on high accuracy mode just use

     Process proc=Runtime.getRuntime().exec(new String[]{"su",
    "pm grant com.your_app_packagename android.permission.WRITE_SECURE_SETTINGS",
    "settings put secure location_providers_allowed gps,network,wifi"});
     proc.waitFor();
    

    Run these command on background thread :)

    further you can refer to this link here

提交回复
热议问题