Home > Software engineering >  how to get all the apps that can open file to arrayList
how to get all the apps that can open file to arrayList

Time:11-29

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

CodePudding user response:

intead of calling startActivity just use

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

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

  • Related