Isaac Wagner wrote:
> Thanks.  I bought a subscription to your books and have actually been
> going through this code trying to figure it out.  If I understand
> correctly this is the snippet of code that handles the refresh button:
> 
> public void onReceive(Context ctxt, Intent intent) {
>     if (intent.getAction()==null) {
>         ctxt.startService(new Intent(ctxt, UpdateService.class));
>     }
>     else {
>         super.onReceive(ctxt, intent);
>     }
> }
> 
> What I'd like to do is expand this code to be able to handle three
> different buttons.  However, I'm not sure how to do that.

In my case, I cheated and used the null action string as my indicator
that it was my broadcast Intent. If you want several, you will need to
use your own action strings for each. If you put both the component:

Intent i=new Intent(this, Foo.class);

and the action:

i.setAction(Foo.THIS_IS_MY_BOOMSTICK_ACTION);

then the Intent will still get routed based on the component, but the
action will be available to help discriminate the incoming Intents
(plus, it keeps them unique from a PendingIntent standpoint).

> Incidentally, that would be a great addition to this widget in your
> book -- adding another button.  I'm not entirely sure what it would
> do, but it would be nice to see an example of handling more than one
> button press (that isn't a configuration app launcher).

I'll add that to my to-do list. Note: it is a really long list. :-)

> Thanks for the books BTW.  They've been helpful.

You are very welcome!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to