1

I would like to enable the location settings on an android machine. In my program I check if the

LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
   ..//
}

If deactive, I would like to activate it programatically.

EDIT: When my location settings are disabled and I call/use googleMaps, I am asked by means of a dialog, whether I want to enable it? If "Yes", the location service is being enabled in the background without callings another user interaction.

Can I enable location settings without having other user interactions?

Martin G
  • 17,357
  • 9
  • 82
  • 98
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
  • you can't and you shouldn't. – Blackbelt Feb 09 '16 at 08:59
  • Possible duplicate of [Turning on and off GPS programmatically in android 4.0 and above?](http://stackoverflow.com/questions/15426144/turning-on-and-off-gps-programmatically-in-android-4-0-and-above) – Kapil Rajput Feb 09 '16 at 09:16
  • 1
    Thing is, Android is Google's property, so if they want to have GoogleMaps programmatically turn GPS on or off, they can. After a quick review of the post by @KapilRajput, and just a quick search online, it looks like you can't do what you are hoping to do. The best you can do is direct them to the Location Settings via an intent. – Pablo Baxter Feb 24 '16 at 22:30

1 Answers1

1

No you cannot. location information is build into the system, which require permission. Android M currently has "permission" build for each app that can set it when app starts. But if user forcefully turn off GPS then the user has to turn it back on him/herself.

Kevin Hwang
  • 179
  • 9