private void turnGPSOn(){ String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if(!provider.contains(\"gps
use SettingsApi if you not want to force user to go settings page to enable gps. here the link of how to use SettingsApi SettingsApi