Possible Duplicate:
How can I enable or disable the GPS programmatically on Android?
android GPS enable programmatically
Need help to switch on GPS programmatically in certain interval of time. Is it possible?
Possible Duplicate:
How can I enable or disable the GPS programmatically on Android?
android GPS enable programmatically
Need help to switch on GPS programmatically in certain interval of time. Is it possible?
Here is the code snippet that can be used for this
private void EnableGPS(){
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);
} }