Strange bug in widget in Android 2.3.3 -
i trying write home screen widget. on widget there few textviews
2 imagebuttons
. 1 refreshing , second opening settings window.
the problem is working on android 4.2.2 , not working on android 2.3.3.
everything looks fine. when buttons pressed don't work. interesting thing is happening on first instance of widget. when second added works ok.
this small part of code, used make update , @ point not working in android 2.3.3:
@override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { log.i(tag, "onupdate"); // widgets ids componentname thiswidget = new componentname(context, dataappwidgetprovider.class); int[] allwidgetids = appwidgetmanager.getappwidgetids(thiswidget); log.d(tag, "widgets id: " + allwidgetids.length); (int widgetid : allwidgetids) { log.d(tag, "widget: " + widgetid); // remote view remoteviews remoteviews = new remoteviews(context.getpackagename(), r.layout.widget_layout); refreshintentsend(context, remoteviews, allwidgetids, widgetid); appwidgetmanager.updateappwidget(widgetid, remoteviews); } super.onupdate(context, appwidgetmanager, appwidgetids); } /** * set , add intent button refresh given widget */ private void refreshintentsend(context context, remoteviews remoteviews, int[] allwidgetids, int widgetid) { intent = new intent(context, dataappwidgetprovider.class); i.setaction(appwidgetmanager.action_appwidget_update); pendingintent pi = pendingintent.getbroadcast(context,0, i,pendingintent.flag_update_current); remoteviews.setonclickpendingintent(r.id.imb_refresh,pi); log.d(tag, "refresh: " + widgetid + " remoteviews: " + remoteviews); }
imb imagebutton
.
does see wrong here?
edit:
checking in onreceive quite interesting outcome. if looks this:
@override public void onreceive(context context, intent intent) { log.d(tag,"intent: " + intent.getaction()); super.onreceive(context, intent); }
or this:
@override public void onreceive(context context, intent intent) { log.d(tag,"intent: " + intent.getaction()); if(appwidgetmanager.action_appwidget_update.equals(intent.getaction())) { log.d(tag,"action"); } super.onreceive(context, intent); }
the logcat looks this:
dataappwidgetprovider(411): intent: android.appwidget.action.appwidget_update dataappwidgetprovider(411): action
when there no override, or after super in onreceive
onupdate
not called @ all.
seems open android issue
http://code.google.com/p/android/issues/detail?id=8889
work around -- ctrl + f11 on emulator or changing orientation of device
Comments
Post a Comment