« Android, "spionprogramvare" og slett journalistikk fra bl.a. Digi.no | Main | Mobilspådommer for 2020 »
mandag
mai312010

How to Create a Simple Share Intent for Android

A simple and basic task to perform from Android apps is the option to share a piece of information. Luckily, Android makes this dead easy. It's probably because it's so easy that my attempt to Google the information didn't give me any results.

Well, next time, I'll hopefully end up at this very page with the following snippet ready to use:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is a text, should probably include a link, like this: http://www.gunnarlium.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "This is an optional subject");
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Share this!"));

When you're done, it will look this:

 

Happy sharing!

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>