[TUT] Add Your App to the Android ‘do something’ Menu (using Intent Filters)

By blundell  

This request is to be able to add your application to the context menus of the android system.

When the android system or another application wants to do a specific task, it will broadcast an intent saying “can anyone do this for me“. Here I’ll show you how you can grab this request so your the one that helps!

The specific tutorial request was to be added to the menu when someone using the Android messaging application hits the ‘attach’ button. I was looking through the Android source code for this and sadly we can’t actually get into the ‘attach’ menu. However you can get selected when the user presses ‘Picture’ or ‘Video’, or any of the other selections.

There’s not much coding to this Google have kept Intents nice and clean. What we need to do is update the intent-filters in our manifest to declare that we are there to handle these broadcasts. An intent-filter is just a way of saying, I am capable of handling this type of data.

Here is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

        android:label="@string/app_name" >
            android:label="@string/app_name" >
                <action android:name="android.intent.action.GET_CONTENT" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="*/*" />


This application has one activity called MainActivity, we have removed the Main action and this means you won’t be able to see the app installed in the apps menu.

We’ve added a new intent filter for ‘Get Content’ meaning if an application requests ‘content’ we are there and will be nominated as one of the applications you can use!

The data tag holds the mime type of any data we can handle, using */* means we can handle all data. If you used image/* you could handle image requests only.
As we are using */* when your activity is started you will need to ask for the type of the data that was sent to you and act accordingly (as you could be sent anything!).

There are many intents that you can capture and this is an example of just one, if you wanted to be used in a different way take a look through the list here. Anything starting with ACTION_ can be used as an intent filter, also this page gives a good insight into how the Manifest constructs intent filters.

Here is the activity that will be started, it doesn’t do anything but thats up to you to implement ;-)


package com.blundell.mediaattach.ui.phone;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.blundell.mediaattach.R;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        // Get intent, action and MIME type
        Intent intent = getIntent();
        String action = intent.getAction();
        String type = intent.getType();
        // You would then use these three variable to figure out who has sent you an Intent and what they want you to do!
        // See here for further instruction: http://developer.android.com/training/sharing/receive.html
        // http://developer.android.com/guide/topics/manifest/action-element.html
        // http://developer.android.com/reference/android/content/Intent.html#ACTION_GET_CONTENT

Thats it! You app will now be shown in the menu when a user chooses attach > pictures.

Because there isn’t much coding I haven’t attached the source, but if you want it just comment and ask. Enjoy!


  1. swati
    Posted October 21, 2013 at 8:07 am | Permalink | Reply


    I have an app where i have some images in a gridview and i want that it the images in the girdview can be attached to whats app attachments and any other chat app’s attachements. I am able to add my app in the share menu of what’s app but I don’t know how to attach the image from my app and send it back to what’s app. Can you help me.

    The action i am recieving when my app is launched from what’s app’s share menu is
    action PICK. How do i attach my image and send it back?

    • blundell
      Posted December 7, 2013 at 10:16 pm | Permalink | Reply

      not completely sure, but it will something to do with putting it into the Intent and using setResult.

  2. Posted October 27, 2012 at 1:22 pm | Permalink | Reply

    With having so much content and articles do
    you ever run into any issues of plagorism or copyright infringement?
    My site has a lot of unique content I’ve either created myself or outsourced but it looks like a lot of it is popping it up all over the web without my agreement. Do you know any techniques to help prevent content from being stolen? I’d genuinely appreciate it.

    • blundell
      Posted October 27, 2012 at 3:46 pm | Permalink | Reply

      Probably, I don’t actually check, if anyone copies I just take it as a compliment, it’s all free. Also I’m sure my website would always come first in search results anyway

  3. philippe45
    Posted April 24, 2012 at 9:13 pm | Permalink | Reply

    Thank you, simple and direct to the goal, with the variables to get values.

  4. Posted April 3, 2012 at 3:05 pm | Permalink | Reply

    Thanks loads for this. This is actually the second best thing i could get. Thanks bunches.

Post a Comment

Your email is never shared. Required fields are marked *