Tag : gps

If you want to develop an Android app to turn on/off GPS you can use the following code snippets. // turn on gps public void turnGPSOn() { Intent intent = new Intent(“android.location.GPS_ENABLED_CHANGE”); intent.putExtra(“enabled”, true); this.ctx.sendBroadcast(intent); String provider = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if(!provider.contains(“gps”)){ //if gps is disabled 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”)); ..

Read more