Android: Problems Forcing Landscape Mode

So I’m trying to get my app to run in landscape mode only on Android. I tried setting the orientation in AndroidManifest.xml to no avail, so I added the following java code in onCreate():

Code:
// Force landscape orientation
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

This does force the orientation to rotate when the app starts. If my phone is already in landscape mode when I launch the app, the app runs fine. However, if the phone is in portrait mode when the app is launched, the app will start, but will be killed after a frame or two and I see the following in the logcat:

Code:
E/libEGL(3988): call to OpenGL ES API with no current context (logged once per thread)
D/dalvikvm(3988): threadid=15: thread exiting, not yet detached (count=0)
I/WindowState(699): WIN DEATH: Window{41ca3af8 u0 SurfaceView}
I/ActivityManager(699): Process (pid 3988) has died.
W/ActivityManager(699): Force removing ActivityRecord{41e487b0 u0 }: app died, no saved state
I/WindowState(699): WIN DEATH: Window{41c8b550 u0 }

So, it appears as though the OpenGL context is somehow getting trashed even though the context isn’t getting created until after the rotation has been done. Is this a bug in SDL? Am I doing something wrong? Is there a better/more appropriate way to force a certain screen orientation with SDL in Android?

2013/8/10 jlev31415

**
So I’m trying to get my app to run in landscape mode only on Android. I
tried setting the orientation in AndroidManifest.xml to no avail, so I
added the following java code in onCreate():

Code:

// Force landscape orientation
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

This does force the orientation to rotate when the app starts. If my phone
is already in landscape mode when I launch the app, the app runs fine.
However, if the phone is in portrait mode when the app is launched, the app
will start, but will be killed after a frame or two and I see the following
in the logcat:

Code:

E/libEGL(3988): call to OpenGL ES API with no current context (logged
once per thread)
D/dalvikvm(3988): threadid=15: thread exiting, not yet detached (count=0)
I/WindowState(699): WIN DEATH: Window{41ca3af8 u0 SurfaceView}
I/ActivityManager(699): Process ** (pid 3988) has died.
W/ActivityManager(699): Force removing ActivityRecord{41e487b0 u0 **}:
app died, no saved state
I/WindowState(699): WIN DEATH: Window{41c8b550 u0 **}

So, it appears as though the OpenGL context is somehow getting trashed
even though the context isn’t getting created until after the rotation has
been done. Is this a bug in SDL? Am I doing something wrong? Is there a
better/more appropriate way to force a certain screen orientation with SDL
in Android?

I do get that “call to OpenGL ES API with no current context (logged once
per thread)” message when I leave my app (to go to the home screen for
example), I always took it as a warning without further consequence
(probably as a product of a harmless race condition between the Java thread
and the native thread). So I don’t think you app is crashing due to that
message, do you perhaps get a crash trace in the logcat before that message?–
Gabriel.

Gabriel, thanks for the reply. There is no crash trace present. The app appears to run fine until the “call to OpenGL ES API with no current context” message, at which point it appears as though the app is terminated. It’s a bit strange. Let me know what I can do to help debug it.

FYI, I have submitted this issue to Bugzilla.