Nuvious Nuvious - 1 year ago 179
Android Question

Programmatically update widget from activity/service/receiver

I know it's possible, but I can't figure out a way to trigger an update of my widget from the main activity. Isn't there some general intent I can broadcast?

Answer Source

If you are using an AppWidgetProvider, you can update it this way:

Intent intent = new Intent(this,MyAppWidgetProvider.class);
// Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
// since it seems the onUpdate() is only fired on that:
int[] ids = {widgetId};
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download