I'm trying to get a list of all applications that are capable of sending text messages.
I found several solutions on that suggest to use the PackageManager.
I think that the Intent to be used is ACTION_SEND, but when i run my code i always receive 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?
You haven't set the MIME type for the Intent. For example:
mainIntent.setType("text/plain");
That will produce results. However, be mindful that this won't exactly return "applications capable of sending text messages", rather those that can accept a text, not necessarily for the purpose of sending a message (as an example, the Google Translate app is capable of receving text).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With