Search code examples
androidandroid-orientationsurfaceholderandroid-configchanges

android:configChanges="orientation" with surfaceChanged


In one activity implementing SurfaceHolder.Callback, I include the line android:configChanges="keyboardHidden|orientation|screenSize" to stop the activity from being redrawn when, among other things, the screen is rotated. However, surfaceChanged() still gets called when the screen is rotated. Is this intentional, and how can I get the behaviour I want, which is to completely ignore rotations?


Solution

  • It seems like there's no better solution than a manual hack: set a boolean variable once surfaceChanged is called for the first time (i.e. when the surface is created), and return at the beginning of surfaceChanged if this variable is set.