Android: Create your own sharing app

One of the first applications I did for Android was a very simple application which simply takes a picture using Camera and then send it to a remote server. Very simple, but it introduced to me into the android world and the notion of activities and communication between different applications.
A little addition to this application I wanted to make was the possibility to share any of the pictures already taken. To do that I wanted to add the application to the list of the choices which appear when an user click on the “share” button when view an image using the default Gallery application.

Nothing easier than that! It was just a matter of a couple of tags to be added to the AndroidManifest.xml and the trick was done!
Here the manifest:

< ?xml version="1.0" encoding="utf-8"?>

The tricky part is to add the two actions android.intent.action.SEND and android.intent.action.CHOOSER to the manifest, and the system will do the rest. In this way, when a user will select the application from the sharing list a new activity will be launched and it will just a matter of checkin which intent has been sent to get the image uri which has to be shared:

[cc]intent.getAction().equals( Intent.ACTION_SEND )[/cc]

This is a screenshot of the device when the “share” button has been pressed