How can i enable and disable GPS programatically
问题 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. 回答1: Here is the code... private void turnGPSOn(){ String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if(!provider.contains("gps")){ final Intent poke = new Intent(); poke.setClassName("com.android.settings","com.android.settings