Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am working on this issue right now, and at this moment it <em>appears</em> to be an Android bug related to SurfaceHolder.setFixedSize(). </p> <p>What I do to get these logs is this: wait for game to load, push power, let screen go blank, push power again (quickly), unlock slide (quickly). This is on HTC Thunderbolt 2.3.4, by the way.</p> <p>Here is the normal course of events (without using setFixedSize):</p> <pre><code>----- power button pushed ------ JavaMain: onPause: called, thread: 1 ActivityManager: Config changed: { scale=1.0 imsi=310/12 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=1509 skin=default} JavaMain: onConfigurationChanged, orientation: 1 thread: 1 JavaMain: mSView(old): 800x480 JavaMain: surfaceChanged: width: 480, height:800, thread: 1 JavaMain: onWindowFocusChanged: called, thread: 1 (screen is now off) ------ power button pushed, and slide-lock undone ----- JavaMain: onResume: called, thread: 1 ActivityManager: Config changed: { scale=1.0 imsi=310/12 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=2 layout=34 uiMode=17 seq=1510 skin=default} JavaMain: onConfigurationChanged, orientation: 2 thread: 1 JavaMain: mSView(old): 480x800 JavaMain: onWindowFocusChanged: called, thread: 1 JavaMain: surfaceChanged: width: 800, height:480, thread: 1 (back in game) </code></pre> <p>Notice, that after onPause, my surface view is redone as portrait and after onResume it is changed back to landscape. I have screenOrientation set to landscape in the manifest.</p> <p>Now look what happens during the same sequence but now SurfaceHolder.setFixedSize() is used (to reduce resolution):</p> <pre><code>----- power button pushed ------- JavaMain: onPause: called, thread: 1 ActivityManager: Config changed: { scale=1.0 imsi=310/12 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=1513 skin=default} JavaMain: onConfigurationChanged, orientation: 1 thread: 1 JavaMain: mSView(old): 800x480 JavaMain: surfaceChanged: width: 640, height:384, thread: 1 JavaMain: onWindowFocusChanged: called, thread: 1 (screen is now off) ------ power button pushed, and slide-lock undone ----- JavaMain: onResume: called, thread: 1 ActivityManager: Config changed: { scale=1.0 imsi=310/12 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=2 layout=34 uiMode=17 seq=1514 skin=default} JavaMain: onConfigurationChanged, orientation: 2 thread: 1 JavaMain: mSView(old): 480x800 JavaMain: onWindowFocusChanged: called, thread: 1 (back in game, with a messed up screen as in OP) </code></pre> <p>Now notice that, after onPause, surfaceChanged reflects the fixed size that I had specified, however upon onResume the surface view is in portrait orientation (somewhat unexpected). <strong>But what is really missing, is the surfaceChanged call with my fixed size parameters.</strong> And before you ask, no doing .setFixedSize() in onConfigurationChanged() does not have any effect.</p> <h2>UPDATE AND SOLUTION:</h2> <p>Indeed, the solution came down to restoring (actually, never allowing any changes to) my surface view. This is accomplished by adding the following two lines after the super call in onConfigurationChanged for your activity. (Asumming you have the following manifest setting set).</p> <pre><code>android:configChanges="orientation" android:screenOrientation="landscape" </code></pre> <p>This effectively prevents the surface view dimensions from ever being set to anything else (such as portrait). <strong>Which, incidentally, IS WHAT I WANTED WHEN I SPECIFIED screenOrientation=landscape !!!</strong> (I'm looking at you here, Google)</p> <pre><code>public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // -- stomp any attempts by the OS to resize my view. // -- Hardcoded values for illustration only. In real life // -- you'll need to save these when the surface view is originally created mSView.getLayoutParams().width = 800; mSView.getLayoutParams().height = 480; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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