Get a list of applications that can handle the SEND intent to display in the view (rather than a popup dialog)

I am trying to get a list of all the applications installed on the phone that are capable of handling the SEND intent. I am currently dealing with this situation using Intent.createChooser, but I am not trying to achieve this, as I would like to access a list of applications to display them in a view in my activity, similar to how the Android Stock Gallery application displays them, NOT in the spinner dialog box.

A screenshot is available here: http://i.stack.imgur.com/0dQmo.jpg

Any help would be greatly appreciated.

+12
android android-intent share send
Jan 31 '12 at 17:12
source share
2 answers

Call queryIntentActivities() on the PackageManager , given the ACTION_SEND Intent , configured just like you would use with createChooser() (i.e. it is of type MIME, Uri , etc.). This will give you a list of all the matches that appear in the selection. Then you can use user selection to trigger the actual activity.

Here is an example project that uses this to create a launch pad.

+17
Jan 31 '12 at 17:17
source share
 List<String> packages = new ArrayList<>(); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "test"); sendIntent.setType("text/plain"); List<ResolveInfo> resolveInfoList = getPackageManager() .queryIntentActivities(sendIntent, 0); for (ResolveInfo resolveInfo : resolveInfoList) { packages.add(resolveInfo.activityInfo.packageName); } 
+4
Feb 17 '15 at 18:40
source share



All Articles