0

I have my android app which gets all installed applications via - queryIntentActivities .

and I need to be able to add my own activity to this list, so I can start it, when this activity is picked, How can I do it?

Thank you on advance.

unresolved_external
  • 1,930
  • 5
  • 30
  • 65

1 Answers1

2

Implement an <intent-filter> on your <activity> which matches the Intent that you are creating. Something akin to:

        <intent-filter>
            <action android:name="android.intent.action.SEND"/>
            <action android:name="android.intent.action.SEND_MULTIPLE"/>
            <data android:mimeType="???"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>

(where ??? would be replaced by whatever APP_DEFALUT_MIME_TYPE is, I guess)

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks, that helped :) And by the way is there any way to pass an uri to this activity through intent? – unresolved_external May 10 '12 at 12:48
  • @unresolved_external: Neither `ACTION_SEND` nor `ACTION_SEND_MULTIPLE` use the data `Uri` in an `Intent`. – CommonsWare May 10 '12 at 13:04
  • So basically, what I need to do is to put uri to my Intent and then parse it will appear in the Bundle of activity which was launched via this Intent? – unresolved_external May 10 '12 at 13:19
  • @unresolved_external: I am sorry, but I do not understand your last comment. I repeat: neither `ACTION_SEND` nor `ACTION_SEND_MULTIPLE` use the data `Uri` in an `Intent`. – CommonsWare May 10 '12 at 13:22
  • @unresolved_external: I have no idea what you are referring to, sorry. – CommonsWare May 10 '12 at 13:41
  • Ok, in android we can set intent type via setData method by passing Uri to it, so if I set it like this, would I be able to get this uri, in activity which was started? – unresolved_external May 10 '12 at 13:57
  • @unresolved_external: If you are using `EXTRA_STREAM` with `ACTION_SEND` or `ACTION_SEND_MULTIPLE`, you put the `Uri` (converted to a string) of the data to be streamed as the value of `EXTRA_STREAM`. Otherwise, there is no `Uri`, and any attempt to use `setData()` is likely to prevent your `ACTION_SEND` or `ACTION_SEND_MULTIPLE` from working in the first place. – CommonsWare May 10 '12 at 14:07
  • Ok, I already figured it out by myself, Thank you for you time. Have a nice day:) – unresolved_external May 10 '12 at 14:09
  • I needed to clean/rebuild my project before my internal Activity showed up in my `queryIntentActivities` list, so if you're doing the above and it still isn't working, a clean might be worth a try. – Matt Gibson Jun 21 '12 at 10:23