Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - onConfigurationChanged() being called before onResume() after pausing Activity
    primarykey
    data
    text
    <p>In my Activity, I override the onConfigurationChanged() method as it's playing a video, and I do not want to wait a second until the system is ready again to continue playing the video after I change my device's orientation. This works just fine - my video keeps playing smoothly and the orientation gets changed, while the video gets rescaled to just fit in the screen dimensions.</p> <p>Yet I discovered a bug when these steps are taken:</p> <ol> <li>I pause my app during video playback</li> <li>I change orientation</li> <li>I "resume" my app</li> </ol> <p>First thing what happens: onConfigurationChanged() gets called, not onResume() after which all my fields should be restored! This causes an Exception with a divide by zero as its cause - some field equals 0 as it's not restored yet. Ofcourse this is not desired behaviour. My app does work when resuming it with the same orientation it's paused in.</p> <p>I can circumvent this, though, by using a boolean indicating whether my Activity has "fully loaded" - that is, the onResume() method has been called. But I consider this not a very clean solution.</p> <p>My question is: </p> <ol> <li>Is this intended behaviour? I consider it weird that onConfigurationChanged() gets called before onResume(). Is this a bug?</li> <li><p>Can I programmatically "unregister" my app from listening to onConfigurationChanged() temporarily (for example, unregister it in the onPause() method)? As this method does not get called because you must register some listener to it, but gets called because you put in your AndroidManifest.xml file this line:</p> <p>android:configChanges="orientation"</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload