Posted: Mon Nov 30, 2009 5:08 pm Post subject: Simple Problem With Intent Extras Hello,
I'm working on an app widget for the home screen. I'm trying to make it so when a user taps on the widget it changes the data being displayed in the widget. However, I'm also allowing multiple instances of widgets open with different data. So in order to tell my method which widget to update, I'm adding an extra to the intent that is launched to change the data.
Here's the intent I have: Java:
Intent changeData = new Intent("com.tonycosentini.mintdroid.CHANGE_DATA");
changeData.putExtra("widget_id", currentWidgetId);
PendingIntent changeDataPendingIntent = PendingIntent.getBroadcast(this, 0, changeData, 0);
//This will return the correct value, but if I call it in my onreceive() method it won't.
Log.v(TAG, "stored id is: " + changeData.getIntExtra("widget", 0);
This correctly stores the widget id, but when the change data method is called, the widget id that is read from the intent is the first widget instance. That is, there is is a for loop that generates all of the widgets and no matter what widget you tap, the widget id that is recieved is always the first widget id in the first widget.
Anyone have an idea on how to solve this? Hopefully I didn't word it too poorly.
Thanks for reading, Tony