0

I didn't find idea Where is the problem? should I write something into Manifest to enable this functionality?

private void toggleGPS(boolean enable) {
    String provider = Settings.Secure.getString(getContentResolver(), 
        Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider.contains("gps") == enable) {
    return; // the GPS is already in the requested state
}

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);

}`

full Error
  • 298
  • 3
  • 7
  • 20

2 Answers2

0

There are different permissions you might add in your Android Manifest.xml for location you might want the following:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Read the manifest permission documentation for more details

marimaf
  • 5,217
  • 3
  • 49
  • 63
0

Yes you need to give permission in manifest.xml of android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS

Ronak Mehta
  • 6,010
  • 5
  • 41
  • 68