title: android turn GPS On & Off Programmatically in 2.2?
body: <p><strong>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
  :(</strong></p>
  
  <p>this is for turn off i need the turn on please</p>
  
  <pre><code>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();
    }
  }
  </code></pre>