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!