okay, so I am understanding this better.

>From my app widget, I can set different OnClickPendingIntent's as long
as I make the "action" different - which I was *not* doing before,
which is why it kept sending the first intent.

    Intent button1Intent = new Intent(context,
MyService.class).setAction("button1Action");
    PendingIntent button1PendingIntent = PendingIntent.getService
(context, 0, button1Intent, 0);

    Intent button2Intent = new Intent(context,
MyService.class).setAction("button2Action");
    PendingIntent button2PendingIntent = PendingIntent.getService
(context, 0, button2Intent, 0);

    remoteViews.setOnClickPendingIntent(R.id.Button1,
button1PendingIntent);
    remoteViews.setOnClickPendingIntent(R.id.Button2,
button2PendingIntent);

Without the setAction(), it looked like the same intent, so even using
putExtra() - it didn't help.  Android would simply reuse the first
pending intent.

So now, my remaining question is how to send events to my app widget
from a service if the app widget is idle -- i.e. does not have a
handle to the service.  The thing i'm trying to do is when the app
widget is idle, use as few resources as possible, so i don't want the
app widget starting a service or doing anything until it is triggered.

I guess I could create a very small local service in my app widget,
that I guess could simply be used as a way for my resource intensive
service to be able to communicate with it...

Hm...

tia.

On Oct 2, 1:04 am, sdphil <phil.pellouch...@gmail.com> wrote:
> I need some help understanding how this works.
>
> I have an app widget that extends an AppWidgetProvider to create an
> application widget.
>
> I would like the application widget to be idle until an activity in my
> app runs; actually when a service in my app is started.
>
> Once that service is started, I need to "wake up" the application
> widget and communicate with it (i.e. tell it things to display).
>
> So I see that AppWidgetProvider simply extends BroadcastReceiver -- so
> does that mean:
> 1. I need to call registerReceiver in my service and tell it to filter
> for certain kinds of events?
> 2. Can I even do #1, or will an AppWidgetProvider *only* accept
> ACTION_APPWIDGET_* intents?
> 3. If #2 is correct, how can I communicate or "wake up" / trigger the
> application widget?
> 4. Can I send events to my app widget using sendBroadcast( intent )?
>
> Then, my app widget has some buttons on it, I need to send an intent
> back to the application (or service).  I see you can do that with
> PendingIntents, but if i send the different intents it to the same
> Activity, it seems to re-use the first created pending intent.
>
> tia.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to