Processing more than one button click at Android Widget
Posted
by dive
on Stack Overflow
See other posts from Stack Overflow
or by dive
Published on 2010-03-18T17:09:41Z
Indexed on
2010/03/18
17:51 UTC
Read the original article
Hit count: 251
Hi, all.
I saw this topic and implement IntentService as describes, but what if I want more that one button? How can I distinguish button from each other? I'm trying to setFlags, but cannot read it at onHandleIntent() method:
public static class UpdateService extends IntentService {
...
@Override
public void onHandleIntent(Intent intent) {
ComponentName me = new ComponentName(this, ExampleProvider.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(me, buildUpdate(this));
}
private RemoteViews buildUpdate(Context context) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.main_layout);
Intent i = new Intent(this, ExampleProvider.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
updateViews.setOnClickPendingIntent(R.id.button_refresh, pi);
i = new Intent(this, ExampleProvider.class);
pi = PendingIntent.getBroadcast(context, 0, i, 0);
updateViews.setOnClickPendingIntent(R.id.button_about, pi);
return updateViews;
}
}
At this little piece of code I have two PendingIntent linked with setOnClickPendingIntent, can I distinguish this intent for different actions and processing? Thanks for help
© Stack Overflow or respective owner