Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically enable the the "Use location?" message in Android?

When I use google maps and have the location settings disabled, I can press the gps icon. When I do this, I get this question message on my device:

Use location? This app wants to change your device settings: Use GPS...

This is a nice alternative for this: https://hedgehogjim.wordpress.com/2013/03/20/programmatically-enable-android-location-services/

because the only thing the user needs to do is select "Yes" or "No" instead of understanding the settings menu, changing it and going back to the app someway.

Like google maps, my app needs location data as well and I strongly prefer the google maps functionality over linking to the settings as described in the http link I posted here.

So how do I add this functionality to my app? In other words, how do I programmatically ensure this question pops up?

like image 335
Daan Avatar asked May 18 '26 10:05

Daan


1 Answers

Take a look at android location settings-enabler APIs: https://developers.google.com/android/reference/com/google/android/gms/location/SettingsApi. This link explains how to invoke a dialog that allows the user to enable the necessary location settings with a single tap.

like image 160
ljmelgui Avatar answered May 21 '26 00:05

ljmelgui