Skip to content
Advertisement

how to get all the apps that can open file to arrayList

how i can get all the apps that can open file to ArrayList? i am using this code to open file:-

         Intent i888777 = new Intent;
    Uri ur888 = (Uri.fromFile(new java.io.File(_path)));
    i888777.setAction(Intent.ACTION_VIEW);
    i888777.setDataAndType(ur888,_type);
startActivity(Intent.createChooser(i888777,_msg));

preview

Advertisement

Answer

intead of calling startActivity just use queryIntentActivities

PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(i888777,
    PackageManager.MATCH_DEFAULT_ONLY);

you can also try with MATCH_ALL flag or whatever you need. more to inspect in DOC

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement