Android queryIntentActivities always returns an empty list

I am trying to get a list of all applications capable of sending text messages.

I found several solutions that suggest using PackageManager.

I think the intention to be used is ACTION_SEND, but when I run my code, I always get an empty list.

This is my code:

Intent mainIntent = new Intent(Intent.ACTION_SEND, null); List<ResolveInfo> pkgAppsList = getApplicationContext().getPackageManager().queryIntentActivities( mainIntent, PackageManager.GET_RESOLVED_FILTER); int size = pkgAppsList.size(); int i = 0; Log.i(TAG, "Size: " + size); for(ResolveInfo infos : pkgAppsList){ String name = infos.activityInfo.applicationInfo.loadLabel(getPackageManager()).toString(); Log.i(TAG, "name: " + name); } 

Any idea?

+7
java android
source share
1 answer

You did not specify a MIME type for the intent. For example:

 mainIntent.setType("text/plain"); 

This will produce results. However, remember that this will definitely not return “applications that can send text messages”, but those that can receive text, and not necessarily to send a message (for example, the Google Translate application is able to receive text).

+13
source share

All Articles