How to turnon/off location services programatically in android
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1051649/how-to-programmatically-enable-gps-in-android-cupcake">How to programmatically enable GPS in Android Cupcake</a>  </p>
</blockquote>



<p>I want to turn on/off location services by using toggle button pressing,
i have code which will call the primary settings page(settings->Location&amp; Sequrity)
but i dont want to go to that page need a code to turnon/off code by pressing toggle button</p>

<p>Here is the code to bring me to primary settings:</p>

<pre><code>LocationManager locationManager= (LocationManager) getSystemService(LOCATION_SERVICE); 
 if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){  
Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(callGPSSettingIntent);    
}
else
{
Toast.makeText(MyRealSettings.this, "Location services in disable mode", Toast.LENGTH_LONG).show();
}
</code></pre>

<p>if the location services are checked it will bring me to primary settings page otherwise simply it will show a toast message</p>

<p>Please show a way to enable/disable location services(Gps) without going to settings page</p>
