Yeah, I'll just add a bit more to this, the addIntentOptions() and
related mechanisms are operating on activities -- so you must declare
the matching <intent-filter> in an activity.  It isn't for use with
broadcast receivers, and thus couldn't be used with a dynamically
registered broadcast receiver either.

There is a common misunderstanding that a broadcast receiver sees all
intents going through the system, but they actually only operate on
intents sent as a broadcast.  For this reasons, in an upcoming SDK the
APIs have been changed a bit to use the word "broadcast" instead of
"intent" -- i.e., BroadcastReceiver, Context.sendBroadcast(), etc.

On Jun 18, 3:46 am, Mark Murphy <[EMAIL PROTECTED]> wrote:
> Kevin Tan wrote:
> > Ideally, I would like to write some independent code that would
> > recognize that the ctrl (or any key) was clicked when a 'file-like'
> > selection was made in another application by the user.
>
> For the purposes of this response, "your application" is the one with
> the intent receiver and "the other application" is the one the user is
> working with.
>
> The closest thing I know of in Android that fits the bill assumes that
> each "file" is actually a Uri to some piece of content.
>
> In that case, if "the other application" happens to populate its options
> menu using addIntentOptions() using something like this:
>
> Intent intent = new Intent(null, myContentUri);
>
> intent.addCategory(Intent.ALTERNATIVE_CATEGORY);
> menu.addIntentOptions(Menu.ALTERNATIVE, 0, new ComponentName(this,
>                         MyActivity.class),
>                         null, intent, 0, null);
>
> Then, if you have an activity or intent receiver that matches the
> Intent, a menu choice will appear in the other application's options
> menu that, when clicked, will trigger your application with the supplied
> Uri. You would then, in your application, do something useful with the
> Uri (e.g., flag it for sharing).
>
> However:
>
> 1. You can't force developers to use addIntentOptions() in their menus,
> so your menu choice may or may not appear in any given activity's
> options menu where you might expect it
>
> 2. If you set your intent filter too broadly, you might get the menu
> option for a whole bunch of Uri types that you can't do anything with.
>
> 3. I think this only works for intent filters declared in the manifest
> (vs. any intent receivers you register on the fly using
> registerReceiver()), though I'm not sure about that.
>
> Hope this helps!
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ -- Available Now!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to