Search code examples
androidgps

How to turn on the GPS on Android


I am developing an android app which needs to activate the GPS.

I read a lot of topics in a lot of forums and the answer I've found is:

it's not possible

But... the "Cerberus" APP turns my GPS on... so... it's possible!

Can anyone help me with this?


Solution

  • No, it's impossible, and inappropriate. You can't just manage the user's phone without their authority. The user must interact to enable GPS.

    From Play Store:

    "Cerberus automatically enables GPS if it is off when you try to localize your device (only on Android < 2.3.3) and you can protect it from unauthorized uninstalling - more info in the app configuration."

    You can do something like this:

    startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));