Android examples for Phone:GPS
turn GPS On
//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 turnGPSOn(Context context) { String provider = Settings.Secure.getString( context.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")); context.sendBroadcast(poke); }// w w w. j av a 2s .com } }