Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is difficult to understand what you mean by: </p> <blockquote> <p>When debugging I noticed that the first widget the widgetid of te second used for updating</p> </blockquote> <p>But, I think I understand your general problem: your AppWidgets are not being updated correctly? After glancing at your code, it looks like your problem could be that appWidgetId is declared as static. Perhaps try removing that keyword.</p> <p>Also, I don't see anywhere in your code a button.</p> <p>EDIT</p> <p>It looks like your appWidgetId is being overwritten. Here is my suggestion, take advantage of the AppWidgetProvider being a broadcast receiver and instead send a broadcast as a result of your PendingIntent button click. You will also have to make sure to pass the appWidgetId as an extra to ensure that the correct widget gets updated. Here is an example, should be in your updateAppWidget method:</p> <pre><code>Intent refreshAction = new Intent(); refreshAction.setAction(MY_CUSTOM_REFRESH_ACTION); refreshAction.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent refreshPendingIntent......... </code></pre> <p>And then in the onReceive override:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { ..... Bundle extras = intent.getExtras(); int appWidgetId = extras.getExtra(AppWidgetManager.EXTRA_APPWIDGET_ID); ..... } </code></pre> <p>And then you should be ready to go, updating the correct widget. One more caveat, make sure to read the documentation on BroadcastReceivers if you have not already. You will have to register to accept MY_CUSTOM_REFRESH_ACTION within the WidgetActivity element in your AndroidManifest. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload