The onUpdate () widget is not called when the Android home screen rotates

I am having problems with my widgets. I am using a Droid 2 phone, and when I open the keyboard, the screen rotates and my widget never calls the onUpdate () function.

In an attempt to debug the problem, I overwrote onReceive () and noticed that after rotating the screen I get an intent action:

com.motorola.blur.home.ACTION_WIDGET_ADDED 

After the screen is rotated, TextViews lose their content, so I need to be able to set the text after the rotation. I usually set the text when calling onUpdate ().

Anyone have any idea why this problem? I'm sure I'm doing something wrong ...

Thanks,

-Jona

+4
source share
1 answer

After much testing and searching on the Internet, 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 latest RemoteViews update.

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

The fix always updates everything on your RemoteViews all at once.

+7
source

Source: https://habr.com/ru/post/1339699/


All Articles