-2

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

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);  
   }  }    
Usman Kurd
  • 7,212
  • 7
  • 57
  • 86