I видел этот раздел и реализовал IntentService как описано, но что, если я хочу больше одной кнопки? Как я могу отличить кнопку друг от друга? Я пытаюсь setFlags, но не могу прочитать его по методу onHandleIntent():
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;
}
}
В этом маленьком фрагменте кода у меня есть два PendingIntent, связанный с setOnClickPendingIntent, могу ли я отличить это намерение от разных действий и обработки? Спасибо за помощь