How to filter specific applications for (general) email intent?

I use the Action Send and createChooser API in my application to exchange a text message using various email applications. But I do not want all the applications that I installed on my device. I want this list of choice on Facebook, Facebook, Gmail and Twitter. 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 the code I'm using.

+4
source share
1 answer

If you know which applications you want, you can create your own choice in the dialog and run a specific intention according to the user's choice.

You can check available applications by calling PackageManager 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 a dialog pops up.

+3
source

All Articles