1

I would like to know the Intent command for Turning ON GPS automatically. I'm developing an Android app, and would like to enable the GPS without navigating to the settings page (Something similar to UBER). I'm looking for the Action/Intent that would trigger the LOCATION_ENABLE settings.

EX: android.settings.LOCATION_SOURCE_SETTINGS_ENABLE (Something similar to This)

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
Antony John
  • 73
  • 1
  • 9
  • If you could do that, there's be no point in having the permission. You can turn it on if its just not currently turned on, but you can't enable it programmatically. – Gabe Sechan Aug 27 '18 at 01:13

1 Answers1

1

You can not enable user's location automatically but you need to request to users if they want to grant location permission to your app.

You will display a dialog to user explaining why do you need permission and depending upon user's interest they can enable or disable it.

For how to request location permission, please have a look at this question

Update:

To open native GPS Settings you can use Settings.ACTION_LOCATION_SOURCE_SETTINGS action like below:

final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
  • Hey! Thanks for the quick reply. I totally agree with your point asking for permission, but I want to know if there is an ACTION Intent Code Line that will bring up the permission? Something similar to what Google's location API does. – Antony John Aug 28 '18 at 13:22
  • @AntonyJohn please check my updated answer. Hope this what you needed – Vikasdeep Singh Aug 28 '18 at 13:47
  • @AntonyJohn my pleasure. Please don't forget to **upvote** my answer as well. – Vikasdeep Singh Aug 30 '18 at 01:15