How do I automatically get/pick the first Application, that handles a specified Intent, as if the user selected the first option in a createChooser() dialog.
In this example choose between applications that send data like emails:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
SendEmailActivity.this.startActivity(Intent.createChooser(1, "Send mail..."));
Please help.
using the answer to this question you can get a list of all the apps with intent
android.content.Intent.ACTION_SENDhere’s a working example I coded below (ends up picking gmail on my device)
**Fair warning – will throw a NullPointerException if no email accounts have been setup
you should add a null check on the variable
pkgAppsListand tell the user no email applications found or have been setupif you want to whitelist what app is being called you can loop through the list checking each package name for a specific package (example: gmail is “com.google.android.gm”)