enabling GPS programmatically not working

后端 未结 4 1143
生来不讨喜
生来不讨喜 2021-01-28 15:31

I am trying to enable/disable (toggle) GPS programmatically in my app via a button click, but it is not working. Please help. My target devices are not rooted.

Here\'s t

4条回答
  •  太阳男子
    2021-01-28 16:03

    You can't enable GPS programatically. The most you can do is open the settings for the user to do that.

    You can do it like this:

    startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 100);
    

提交回复
热议问题