In my application on button click I'm maKing the Gps "ON" or "OFF"
If GPS is ON then If we press home button, application will go to background then when the application comes to foreground once again the GPS should be in enabled(ON) position
something like this
final LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
boolean statusOfGPS = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if(statusOfGPS == true){
keep the GPS in "ON" position
}
else if(statusOfGPS == false){
keep the GPS in "OFF" position
}
How can we implement in oncreate() , so that when the application starts we can set the gps on or off by reading the state
Help is always appreciated! Thanks