Search code examples
androidgpsandroid-gps

Turn on/off gps using button without getting into setting menu


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.


Solution

  • 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));