I want to ask about turn on gps in android without getting into setting menu. 1. Does that method possibly to do? 2. If yes how to do that? Thank you.
Asked
Active
Viewed 406 times
-2
-
Possible duplicate of [How to show enable location dialog like Google maps?](https://stackoverflow.com/questions/29801368/how-to-show-enable-location-dialog-like-google-maps) – oldcode Sep 14 '17 at 04:47
1 Answers
0
it is impossible. Only user can turn on/off GPS.
That is done because you shouldn't be able to get user's location if he doesn't want you to get it.
Only thing that you can do is to ask him to turn it on/off by opening GPS settings:
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));

Vladyslav Matviienko
- 10,610
- 4
- 33
- 52
-
1It's not impossible. It can be achieved via LocationSettingsRequest.Builder. Have a look here: https://stackoverflow.com/a/33254073/5352802 – camelCaseCoder Sep 14 '17 at 06:51
-
@camelCaseCoder, as I said, there still is no way to enable GPS. Your approach only will show a dialog. But it is still better than just taking user to the settings – Vladyslav Matviienko Sep 14 '17 at 06:56
-
-
1