Android examples for Phone:GPS
turn GPS Off
//package com.java2s; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.provider.Settings; public class Main { public static void turnGPSOff(Context context) { String provider = Settings.Secure.getString( context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if (provider.contains("gps")) { //if gps is enabled 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")); context.sendBroadcast(poke); }//from ww w . j ava2s . com } }