Android Series: Utilizing Camera 'Share via.." option

Android Series: Utilizing Camera ‘Share via..” option

If you have ever build an android app which required you to use a camera, you should consider a different flow in your application, starting not from your app itself but from the built in android Camera application.
Let’s say you want to post a photo on twitter or facebook. In you standard flow you would open the application XXX, choose the options to take the photo and finally go to the activity responsible for sending that photo.
There is another way to do it, user chooses to open internal andorid Camera application, takes the photo and then chooses ‘Share via..’ option menu.
This is how to include your activity for handling image taken by the external Camera app in the ‘Share via ‘ option list.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".AndroCamera"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
        <activity android:name=".CamSender"
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />

Assuming AndroCamera is the main activity, where a standard application flow starts, and CamSender activity is responsible for manipulating/sending the photo only.
To get the data in the activity responsible for handling received image you should call getExtras(..) and retrieve the data stream

package com.softwarepassion.androcamera;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class CamSender extends Activity {

    private Uri imageUri;
    private ImageView imageView;
    public void onCreate(Bundle state) {
        imageView = (ImageView)findViewById(;
        imageUri = (Uri) getIntent().getExtras().get(Intent.EXTRA_STREAM);

One response on “Android Series: Utilizing Camera ‘Share via..” option

  1. Zulfiqar June 7, 2011 at 9:16 am

    Dear, when we register for intentFilter, there are plenty of options already added., what can we do to make our application option to come first in the options menu list generated by sytem for shareimage menu…
    can we set any kind of priority to do this

Leave a Reply