Android 4.1.2 How to turn off GPS programmatically
adt, android, gps
Solution
Android Guidelines have changed above version 4.0. You cannot change GPS off on programmatically for versions above 4.0. However, you can change wifi off on programmatically
Problem
I am trying to switch on GPS by code. The following is the code I've used. ``` 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); ``` The code executing in OnReceive function. What am I doing wrong?