Orientation code appWidget

I have a code in appwidget that I want to run when the orientation of the phone changes on the main screen, for example, when the keyboard is twisted. I have an image that I want to change in the image view in my application. I can’t use different layouts related to orientation (ie “Layout” and “Layout-Ground”), because I don’t know the name of the image file until runtime, it is created at runtime. Do I need to run the code to run at all, only if the main screen is displayed, my appwidget is active and the orientation has just changed?

I could listen to the configuration_change broadcast, but this will start every time the phone switches to landscape or portrait, and I want this to happen when the desktop is displayed. I cannot think of any good way in android to do this. Thanks

Ryan

+3
source share
3 answers

It is not possible to do this for images generated at runtime.

One approach is to create both versions of the image and have two ImageViews that are visible depending on the layout / layout used. (So ​​RemoteViews will update both ImageViews, but only the correct one will be visible.)

+3
source

, ? , , RemoteView , XML - .

0
0

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