I am developing a game (sort of) which uses OpenGL and has background music. Application runs only in landscape mode.
Problem I have, happens when user locks screen. At that point onStop()
is called, screen orientation is changed and soon after my Activity is restarted as a result of orientation change. This means OpenGL surface is recreated, music starts playing again and all sorts of other things. This is counter-intuitive as locking screen should suspend CPU intensive operations, not start them.
Adding android:configChanges="orientation"
to manifest did nothing. I do realize that I am probably missing screenSize
in android:configChanges
but I can not add it since I am targeting earlier API versions which do not have this option available.
So, question is: What's the proper way to handle this? On which event should I initialize my application so that everything works as expected?