1

I did peel the documentation in order to see if there is any method that can check if a particular Settings exists on the current device but I did not find anything.

For example, I would like to do the following:

if "Settings.ACTION_DATA_ROAMING_SETTINGS" exists on the current device then ...

If anyone has the answer, I'm taker.

Gregordy
  • 597
  • 7
  • 18
  • Are you looking for http://stackoverflow.com/questions/15407502/how-to-check-if-an-intent-can-be-handled-from-some-activity – tachyonflux Jan 14 '15 at 04:35

1 Answers1

1
    Intent intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS, null);
    List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);

Run the above code to check whether there are some components that handle this specific action. If the activities is not empty, the answer is yes.

Better Shao
  • 455
  • 4
  • 10
  • Thank you, it seems that it is working but even though the Settings.X exists, my app is crashing when she's trying to run the intent. I'm using an old Android version(2.3.6) is there any relation? – Gregordy Jan 14 '15 at 05:06
  • @Gregordy Please include the stacktrace from logcat so that we can see what's the cause of the crash. – Better Shao Jan 14 '15 at 05:15
  • It's an ActivityNotFoundException – Gregordy Jan 14 '15 at 05:25