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
source
share