I am developing an application wherein I want to enable GPS, when I start my activity and I want to disable GPS when I exit my application. Can I do it through my program..
Any help would be appreciated.
I am developing an application wherein I want to enable GPS, when I start my activity and I want to disable GPS when I exit my application. Can I do it through my program..
Any help would be appreciated.
Here is all I can find (my code doesn't run in an activity so I have an ApplicationContext class that I call a static method getInstance. You don't have to do this in an activity. Sorry for the code formatting):
If I am not mistaken, you can't do it entirely programmatically. The best is to fire an intent to start the settings page but subsequently user must enable the gps setting in the settings page.
You can't do it in the background without user intervention.
I researched about this subject on all web sites. and I found this code like below. I tried its working.
Method-1
Method-2
Fore more information you can visit this web site : http://androidmaterial.blogspot.com/2012/04/how-to-enabledisable-gps-in-android.html
GpsSettings
Here is the code...
To Disable the GPS through your code,