I have multiple widgets. On update for each i start a service Code in service:
for (int widgetId : allWidgetIds) {
// Register an onClickListener for DisplayActivity
Intent clickIntentUpdate1 = new Intent(
this.getApplicationContext(), DisplayActivity.class);
clickIntentUpdate1.putExtra("widgetid", widgetId);
clickIntentUpdate1.putExtra(DisplayActivity.WHAT, what);
clickIntentUpdate1.putExtra(DisplayActivity.WHAT_COLOR, prefs
.getString(QuoteConfigure.PREF_PREFIX_KEY_QUOTE_COLOR
+ widgetId, "Transparent"));
clickIntentUpdate1.putExtra(DisplayActivity.WHO, who);
clickIntentUpdate1.putExtra(DisplayActivity.WHO_COLOR, prefs
.getString(
QuoteConfigure.PREF_PREFIX_KEY_QUOTE_BY_COLOR
+ widgetId, "Transparent"));
clickIntentUpdate1.putExtra(
DisplayActivity.BG_COLOR,
prefs.getString(QuoteConfigure.PREF_PREFIX_KEY_QUOTE_BG
+ widgetId, "Transparent"));
PendingIntent pendingIntentUpdate1 = PendingIntent.getActivity(
getApplicationContext(), 0, clickIntentUpdate1,
PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.what,
pendingIntentUpdate1);
Log.d("quoteSERVICE", what + " -> " + who);
Log.d("quoteSERVICE", "what inside intent:"+clickIntentUpdate1.getExtras().getString(DisplayActivity.WHAT));
Log.d("quoteSERVICE", "widgetid:"+widgetId);
Log.d("quoteSERVICE", "--------------------");
// Register an onClickListener for Who search
Intent clickIntentSearch = new Intent(Intent.ACTION_VIEW);
clickIntentSearch.setData(Uri
.parse("http://www.google.com/search?q=" + who));
PendingIntent pendingIntentSearch = PendingIntent.getActivity(
getApplicationContext(), 0, clickIntentSearch, 0);
remoteViews.setOnClickPendingIntent(R.id.who,
pendingIntentSearch);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
}
stopSelf();
Now the problem is:
I have two widgets and when they update intent on R.id.who is fired as it is supposed to be with the required data. However the event for R.id.what is not fired as it is supposed to be. The data sent on this event is the last values of what and who sent(i.e. the ones in the last widget to be updated.)