开发者

Widget onUpdate() is not called when Android home screen rotates

I'm currently having issues with my widget. I'm using a Droid 2 phone and开发者_Go百科 when I open the keyboard the screen rotates and my widget never calls the onUpdate() function call.

In efforts to debug the issue I overwrote the onReceive() and noticed that after the screen is rotated I get the intent action:

com.motorola.blur.home.ACTION_WIDGET_ADDED

After the rotation of the screen the TextViews loose their content so I need to be able to set text after the rotation. I usually set the text at the onUpdate() call.

Anyone have any ideas why this issue? I'm sure I'm doing something wrong...

Thanks,

-Jona


After a lot of testing and searching online I realized something so important about Widgets.

When the screen is rotated and the widget needs to be restored the Android system will restore it using the data from the last RemoteViews update.

I was updating parts of the widget separately so when it needed to restore only one part got updated.

The fix is always update everything on your RemoteViews all at once.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜