android - update multiple home screen widget from activity -
i have 2 widgets on home screen. know how update single widget main activity. following code updates single widget when press button on main activity.
@override public void onbackpressed() { intent intent = new intent(this, todo_widget.class); intent.setaction("android.appwidget.action.appwidget_update"); int[] ids = appwidgetmanager.getinstance(getapplication()) .getappwidgetids( new componentname(getapplication(), todo_widget.class)); intent.putextra(appwidgetmanager.extra_appwidget_ids, ids); sendbroadcast(intent);} but both widgets not updating if put code :-
@override public void onbackpressed() { intent intent = new intent(this, todo_widget.class); intent.setaction("android.appwidget.action.appwidget_update"); int[] ids = appwidgetmanager.getinstance(getapplication()) .getappwidgetids( new componentname(getapplication(), todo_widget.class)); intent.putextra(appwidgetmanager.extra_appwidget_ids, ids); sendbroadcast(intent); intent intent1 = new intent(this, todo_widget2.class); intent1.setaction("android.appwidget.action.appwidget_update"); int[] ids1 = appwidgetmanager.getinstance(getapplication()) .getappwidgetids( new componentname(getapplication(), todo_widget2.class)); intent.putextra(appwidgetmanager.extra_appwidget_ids, ids1); sendbroadcast(intent1); this.finish(); } please me out of this. how update both widgets when press button or when main activity created?
Comments
Post a Comment