I am using the following code to share information from my application.
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "share Content" );
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "share subject" );
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share Place via"));
The above code displays some options through which i can share, What i would like to achieve is somehow go through the options and omit some of them.
For Example , in my case, if Facebook app is present on the device, the above code displays it as one of the options. As i already have Facebook android sdk integrated in my application. I want to remove the Facebook option from the sharing options.
I think you should have a look at the
PackageManagerqueryIntentActivities (Intent intent, int flags)methods. This will give you a list ofActivitiesmatching yourIntentand then you can maybe remove some of them, and present a customDialogto the user, where you show just the desiredActivities. And after the user chooses anActivityyou’ll have to explicitly start thatActivity.