Android Widget Refresh

Chris picture Chris · Dec 2, 2010 · Viewed 8.1k times · Source

I have implemented a widget but have problems refreshing it. I get the initial onUpdate , and again if I leave it for ages.

However I want changes in my main application to be automatically reflected on the widget. How do I get that to refresh ? Is there a way of calling the widget from my Activity (do I just do a static routine) or is there a way I can force my "onUpdate" to be called each time the phone returns back to the home screen ?

Answer

GeekYouUp picture GeekYouUp · Dec 2, 2010

Did you implement your widget using a service to update the RemoteViews? If so you can kick off that service with an Intent and the widget will update.

Intent widgetUpdateIntent = new Intent(context, MyClassName.UpdateService.class);
context.startService(widgetUpdateIntent );