I'm trying to get the list of all apps installed on a phone capable of handling the SEND intent. I am currently handling this situation by using Intent.createChooser but this is not what I am trying to achieve as I would like to be able to get access to the list of apps to display them in a View in my activity, in a way similar to how the Android stock Gallery app displays them and NOT in a spinner dialog.
Screenshot available here: http://i.stack.imgur.com/0dQmo.jpg
Any help would be greatly appreciated.
Call queryIntentActivities()
on PackageManager
, given an ACTION_SEND
Intent
configured as you would use with createChooser()
(i.e., has the MIME type, Uri
, etc.). This will give you a list of all the matches that would appear in the chooser. You can then make use of the user's selection to launch the actual activity.
Here is a sample project that uses this to create a home screen-style launcher.
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);
}