java - Android Widget Not Updating More than once -
hi have simple widget showing message unread count , i'm triggering widget update every few seconds (via service , appwidgetprovider) , widgetprovider onupdate called new value every few seconds widget view not updating more once after first update , may cause problem ? here's onupdate code triggered not working more once
for (int = 0; < count; i++) { appwidgetmanager manager = appwidgetmanager.getinstance(context); remoteviews remoteviews = new remoteviews(context.getpackagename(), r.layout.notification_widget_count); if (unreadcount > 0) { remoteviews.setviewvisibility(r.id.notification_widget_count_root, view.visible); // remoteviews.setimageviewbitmap(r.id.notification_widget_count_image_text, m.getfontbitmap(context, unreadtext, context.getresources().getcolor(r.color.white), 25)); remoteviews.settextviewtext(r.id.notification_widget_count_text, new date().getseconds()+""); intent mainintent = new intent(context, mainactivity.class); mainintent.setaction(action_widget_click_main); pendingintent mainpendingintent = pendingintent.getactivity(context, 0, mainintent, 0); remoteviews.setonclickpendingintent(r.id.notification_widget_count_main_root, mainpendingintent); manager.updateappwidget(appwidgetids[i],remoteviews); log.d("ffff-notificationwidget", "updating widget info..."); } else { remoteviews.setviewvisibility(r.id.notification_widget_count_root, view.gone); manager.updateappwidget(appwidgetids[i], remoteviews); }
thanks in advance help
if use service try this
componentname thiswidget = new componentname( getcontext(), <providerclass> ); appwidgetmanager.getinstance( getcontext() ).updateappwidget( thiswidget, rempoteviews );
wiki
Comments
Post a Comment