3

The following code is launching gps setting screen in samsung device but in htc device it is launching security screen of setting.How can i write code so that it will launch gps screen independent of the devices.Please help is there any alternative solution

final ComponentName toLaunch = new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
            final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setComponent(toLaunch);
            startActivity(intent);
android
  • 570
  • 1
  • 6
  • 13

2 Answers2

5

Get rid of the setComponent() and addCategory() calls and see if that helps. You should not be using those in any case, particularly the ComponentName that hard-wires in invalid package and class names.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
-1

I think this code is helpful for you

Intent intent1 = new Intent(); intent1.setClassName("com.android.settings", "com.android.settings.SecuritySettings"); context.startActivity(intent1);

user4232
  • 592
  • 1
  • 12
  • 37
  • 2
    This doesn't work on all devices (e.g. JellyBean/4.1) since the settings for geo have been moved around a bit. – Stefan Hoth Oct 02 '12 at 13:15