Possible Duplicate:
How can I enable or disable the GPS programmatically on Android?
I want to get latitude and longitude programmatic in Android app. But it depended upon whether the GPS is enabled or not. I used to check the GPS with this code
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
{
if(!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER ))
{
Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
startActivity(myIntent);
}
}
But it basically shows the screen to enable it. But I don't want that user should enable it. It should enable automatically if the gps is disabled.