Question

How to get default applications set by users in android through code? I know we can get the default application's package name through packageManager for a particular MIME type. But is there a way to get a list of all the applications registered as default for opening various files?

Was it helpful?

Solution

Use PackageManager.getPreferredActivities()

    final PackageManager pm = getActivity().getPackageManager();

    final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
    filter.addCategory(Intent.CATEGORY_LAUNCHER);

    List<IntentFilter> outFilters = new ArrayList<IntentFilter>();
    outFilters.add(filter);

    List<ComponentName> outActivities = new ArrayList<ComponentName>();
    pm.getPreferredActivities(outFilters, outActivities, null);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top