-1

I have read many posts but I am not able to do it. Please help it's very important.

  • 1
    You have read many posts, but how much code did you tried before running into this issue? See [this tutorial](http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/) and try some code, if you are stuck then , ask here. – Talha Mar 01 '16 at 16:29
  • try this guid https://developers.google.com/android/reference/com/google/android/gms/location/SettingsApi – ELITE Mar 01 '16 at 17:02

3 Answers3

2

Fortunately, this is not possible for privacy reasons, except perhaps on rooted devices or by system apps. All former hacks allowing this have long since been closed.

If you are using Play Services, as part of their fused location provider there is a SettingsApi that you can use that you can use to pop up a dialog and allow the user to have one-click ability to enable GPS.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Try this code, it open automatically settings->location

Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(intent, RESULT_GPS);
Jignesh Goyani
  • 1,020
  • 9
  • 17
-2

android 4.0.4 - only gps notification is enabled. not the gps itself. This solution work for me from 4 and higher

startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
litelite
  • 2,857
  • 4
  • 23
  • 33
Lotfi Bouhout
  • 81
  • 1
  • 3