i am using GPS in My application and i want to turn GPS on and off Programmatically to save power how can i do it :(
this is for turn off i need the turn on please
private void turnGPSOnOff(){
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.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
sendBroadcast(poke);
//Toast.makeText(this, "Your GPS is Enabled",Toast.LENGTH_SHORT).show();
}
}