I want to use Android Intent.ACTION_SEND for quickly sharing something. So I got a sharing list like this:
But I want to share different content for each action, such as:
If sharing by Email/Gmail, content should be "Share by email".
If sharing by Facebook, content should be "Share by Facebook".
So, is it possible to do that?
Not sure if you are still looking for an answer, but ClickClickClack has an example implementation of how you can intercept the ACTION_SEND intent and choose based off package name and certain characteristics what ends up happening. In involves most of the steps mentioned by Tomik.
http://clickclickclack.wordpress.com/2012/01/03/intercepting-androids-action_send-intents/
One powerful aspect about this implementation is you can add analytics to your calls.
There is not direct method to access such kind of information....
Step 1: Inside your code first of all you need to declare an adapter which will contain your custom view of list to be shared on...
Step 2: Now you have create a layout inflater for your adapter(ShareIntentListAdapter.java)
Step 3: Create your xml layout type to show list view in dialog box(social_share.xml)
You can't get such information.
Unless you create your own implementation of the dialog for the activity selection.
To create such dialog you need to use
PackageManager
and itsqueryIntentActivities()
function. The function returnsList<ResolveInfo>
.ResolveInfo
contains some information about an activity (resolveInfo.activityInfo.packageName
), and with the help ofPackageManager
you can get other information (useful for displaying the activity in the dialog) - application icon drawable, application label, ... .Display the results in a list in a dialog (or in an activity styled as a dialog). When an item is clicked create new Intent.ACTION_SEND, add the content you want and add the package of the selected activity (
intent.setPackage(pkgName)
).Using Tomik great Answer i'm able to produce my own Custom share List using PackageManager loadLabel and LoadIcon: