Note that there are some explanatory texts on larger screens.

plurals
  1. POActivity return to Portrait when Screen is Locked
    primarykey
    data
    text
    <p>Related questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/15648713/strange-behaviour-while-screen-lock-in-landscape">https://stackoverflow.com/questions/15648713/strange-behaviour-while-screen-lock-in-landscape</a></li> </ul> <hr> <p>This is a strange behaviour i got in my Activities.</p> <p>Portrait mode (It's normal)</p> <ol> <li>Press screen lock, <code>Activity: onPause()</code>;</li> <li>Unlock the screen, <code>Activity: onResume()</code>.</li> </ol> <p>Landscape mode (It's strange)</p> <ol> <li>Press screen lock, <code>Activity: onPause() -&gt; onStop() -&gt; onDestroy() -&gt; onCreate() -&gt; onStart() -&gt; onResume()</code> which loads the <em>Portrait</em> layout;</li> <li>Unlock the screen, <code>Activity: onPause() -&gt; onStop() -&gt; onDestroy() -&gt; onCreate() -&gt; onStart() -&gt; onResume()</code> and loads the <em>Landscape</em> layout.</li> </ol> <p>What I expect is:</p> <p>Portrait mode: (same)</p> <p>Landscape mode: (should act like Portrait mode)</p> <ol> <li>Press screen lock, <code>Activity: onPause()</code>;</li> <li>Unlock the screen, <code>Activity: onResume()</code>.</li> </ol> <p>So my questions:</p> <ul> <li>Why does my Activities behave like this?</li> <li>How does your Activities behave?</li> </ul> <hr> <p>Original text description of my question:</p> <p>While i press the Lock Screen button of my phone, when my Activity is at its Landscape mode, i noticed (in the debug messages i output to Eclipse) the Activity is re-created to its Portrait mode (while the screen is all black, of course). Then when i press the Lock Screen button again to unlock the screen, the Activity was destroyed and re-created to its Portrait again.</p> <p>As i remember (not 100% sure though), and what i expect is, my Activity should only undergo <code>onSaveInstanceState()</code> and <code>onPause()</code>, while Lock Screen in Landscape mode, like what it does in Portrait mode. Rather than re-creating the Activity to Portrait and going back to Landscape again.</p> <p>Is it that i have messed up something with my phone? How can i fix it back to normal?</p> <p>Thanks!</p> <hr> <p>Thanks everyone for contributing into this issue. Especially thanks @HoanNguyen for his effort of testing for me in his devices. And Especially thanks @Raghunandan for having an in-depth discussion with me concerning this issue.</p> <p>Summarising everyone's contributions so far, i have the following conclusions:</p> <h1>1. This is a normal phenomenon.</h1> <p>It seems that, on mobile phones, the running Activities, that are in Landscape mode, are switched into Portrait mode upon screen lock is a normal behaviour. At least it is true on the tested phones so far. So we have to make sure our lifecycle functions can take care this change elegantly always.</p> <h1>2. Guess this is because of the "default orientation" in the locked screen.</h1> <p>We do not have documentation or many resource talking about this issue. But the assumption that the running Activities switching back to the device's "default orientation" upon screen lock, as in most devices the locked screen is in Portrait, is quite logical.</p> <h3>Further study:</h3> <p>I just wonder how the Activities behave if we are having a landscape locked screen?</p>
    singulars
    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.
 

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