Android 4.1.2 How to turn off GPS programmatically

前端 未结 5 625
有刺的猬
有刺的猬 2020-12-05 22:20

I am trying to switch on GPS by code. The following is the code I\'ve used.

String provider = Settings.Secure.getString(context.getContentResolver(),Settings         


        
5条回答
  •  广开言路
    2020-12-05 22:48

    How to turn off GPS programmatically

    The GPS radio will be on so long as:

    • It is enabled
    • One or more apps are trying to obtain the user's location via GPS

    You are welcome to have your app no longer try to obtain the user's location. However, whether the GPS is on is outside of your control.

    I try to use this code. But nothing happening.

    That is good, because the security flaw that you are trying to exploit has long been fixed.

    Apps cannot enable or disable GPS programmatically, except perhaps on rooted devices. Please allow the user to do that.

提交回复
热议问题