How to filter specific applications for (share) Email intent?
I am using Action Send and createChooser APIs in my app to share some text message through various Email apps.But I dont want all the apps that i have installed in my device.I want specifically facebook,Gmail and Twitter to be in the that chooser List.How to filter like this?Thanks
String TEXT = "I shared the file " + " via MyApp";
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, TEXT);
startActivity(Intent.createChooser(sendIntent, "Share the program:"));
This is 开发者_如何学Pythonthe code I am using.
If you know, which apps you want, you can create your own chooser in a Dialog, and fire the specific intent according to the user's selection.
You can check available applications by invoking PackageManager's queryIntentActivities:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
List pkgAppsList = context.getPackageManager().queryIntentActivities( sendIntent, 0);
And then you select the ones you need and pop up the dialog.
精彩评论