Wrong Extras being passed with Intent in Widget

Put your problem here if it does not fit any of the other categories.

Wrong Extras being passed with Intent in Widget

Postby pcm2a » Mon Oct 12, 2009 11:29 pm

I have two buttons that both need to call the same broadcast. The only difference is I need a different "Extra" sent depending on which is clicked.

I have an extra I set "HELLO" -> 111 and 222. No matter which button you press 222 gets passed. If you remove the extra from the second block then 111 gets passed. How do I make Android pay attention to the extra data better?

Code: Select all
Intent intent1 = new Intent(context, StartStopBroadcast.class);
intent1.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent1.putExtra("HELLO", 111);
intent1.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
         startStopIntent1.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { appWidgetId });
         startStopIntent1.setData(Uri.withAppendedPath(Uri.parse(BaseConstants.URI_SCHEME + "://widget/refresh/"), String.valueOf(appWidgetId)));
PendingIntent pending1 = PendingIntent.getBroadcast(context, 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
remoteView.setOnClickPendingIntent(R.id.button1, pending1);


Intent intent2 = new Intent(context, StartStopBroadcast.class);
intent2.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent2.putExtra("HELLO", 222);
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
         startStopIntent1.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { appWidgetId });
         startStopIntent1.setData(Uri.withAppendedPath(Uri.parse(BaseConstants.URI_SCHEME + "://widget/refresh/"), String.valueOf(appWidgetId)));
PendingIntent pending2 = PendingIntent.getBroadcast(context, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
remoteView.setOnClickPendingIntent(R.id.button2, pending2);
pcm2a
Developer
Developer
 
Posts: 27
Joined: Tue Aug 11, 2009 4:54 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests