Very often, you might want to enable the ability for users to share some content (either text, link or an image) from your Android app. Users can share the content using email, twitter, Facebook, sms or through numerous other ways.
The users might already have installed some custom apps for each one of the above service. So instead of coding all these again, it would be really nice (for both your users as well as for you as a developer) if you can invoke any one of these apps, where users want to share content from your app.
Sharing text
Android provides a built-in Intent called ACTION_SEND for this purpose. Using it in your app is very easy. All you have to do is to use the following couple of lines.
In my phone, it invokes the following dialog box listing the apps that have registered to get notification for this intent.

Sharing binary objects (Images, videos etc.)
In addition to supporting text, this intent also supports sharing images or any binary content. All you have to do is to set the appropriate mime type and then pass the binary data by calling the putExtra method.
Registering for the Intent
If you want your app to be listed when this Intent is called, then you have to add an intent filter in your manifest.xml file
android:mimeType specifies the mime type which you are interested in listening.
Happy sharing
Hi,
Thank you for this tuto, it’s very clear.
My problem is I don’t know java…
I’m using App Inventor to create my applications,
as a newbie I’m struggling to find out a way to call the sharing list which is exactly what you are describing here, but it seems that no one knows (or at least shares) yet how to do it in AI (apparently with “activity starter” component but how?).
Would it be possible for you to give us some ideas ? That would be much appreciated for us as AI users.
I am not sure if this can be done using App Inventor.
Thanks, amazing information!
So if I wanted to sent an array of binary bytes, what would the appropriate mime type be?
Hi all,
Thanks for this useful guidelines. Am new to this Android application coding. I need a small favor, actually out of those items “Facebook, Gmail, Mail, Messages and Peep”. is it possible to display only “Facebook, Gmail”. I need answer for this very much in urgent, Kindly do help me out in this. Thanks in advance
Raghu,
This will list down all applications that have registered to receive that Intend. If you need only a few, then you may have to implement the entire menu yourself as part of your application.
Share your adventures, photos with Gowalla Android app.
http://bstdownload.com/reviews/gowalla-3/
hi Sudar,
thanks for sharing your knowledge.
How can we copy and paste like functionality for Images.
Using ClipBoard we can copy text that I know.
pls suggest me way to do this.
thanks lot
Hello
I had used your app and able to launch Sharing Screen as you shown but it is not working means[Functionality].
Like selecting Bluetooth its able to Scan Device but not getting connected.
Any help
Check your error log and let me know if you are getting any exceptions there.
Hi, I want show the HTML file on facebook wall and did the same as above but the share option menu showing only mail, gmail and bluetooth. It’s not showing facebook or other options.
Note: I have included the code in menifest too.
Thanks
Do you have any Facebook app installed in your phone or emulator?
Yes, I have already installed facebook app for android. Thanks
for setType(“text/html”) facebook app is not showing in list. And if i user “text/plain” facebook twitter apps shows. But in facebook my data has not been sent and blank string will display in facebook app.
Any help will be appreciated. I want to send message in facebook app.
It seems that only urls can be shared in facebook, your texts does not appear.
Thanks for the article.
It turns Sharing content in Android is easy.
Thanks a lot….superb code
Thanks a lot for the post, but the code opens up a text editor on my device. Any suggestions on what am missing out?
> If you want your app to be listed
Listed?
Listed where?
And why would I want (or not want) this optional “listed” thing?
hi i am d learner….plz mail d code… Were i wll get this code to download……..
@Carol: Listed in the list of applications which are displayed if an sharing intent is triggered.
Hi all,
Thanks for this useful guidelines. Am new to this Android application coding. I need a small favor, actually out of those items “Facebook, Gmail, Mail, Messages and Peep”. is it possible to display only “Facebook, Gmail”. Kindly do help me out in this. Thanks in advance
Neeraj,
That’s not possible, since Android builds this list based on the list of apps that are installed in the phone.
i want to do when data share by intent using above code then how i receive data shared by intent. any one help me
how i get data shared by intent using broadcast receiver???
hi,
i want to create a new app,here the main thing is to share the images.
It has the online chatting feature so whille chatting i want to share images
to a perticular online member.Please give me some idea about this.
Thanks in advance.
This is very useful, thanks!
After trying this code, i was able to embed sharing, but the SMS option (Messaging) did not appear.
What’s the trick ?
hello. can I do this share list in php?
You can’t run PHP code in Android.
You not understand me.
I’m want to run this code in front-end of wordpress site.
Is it possible?
No it is not possible. This is an Android app code which can only run in an Android device.
you mention a possibility of sharing a link, but your example doesnt feature code explaining how to do link sharing. is it just a case of checking the “sent text” to see if it is a URL somehow or is there a specific intent filter for dealing with links/urls?
You might also have to change the mime:type.
Its HelpFull But I have Confuse Where I can Start.When i Click menu button show options menu in that share option select show the dialog what shown above how to integrate all in to my application please provide the step by step process for sharing image .
not working on facebook and linkedin,whtasapp, viber etc.
only working in email/gmail
Sharing an image (binary object) only works if the image is stored on the sd card (not in getFilesDir() oder getCacheDir() directories)! Otherwise there’s an error saying “could not add image to your message” (if shared with a messaging service).