Tuesday, March 5, 2013

Re: [android-developers] Re: how to tell why Activity.onPause() is called


Oh my god, really? We are in 2009 again or something? Since Android 3.0, you can call setPreserveEGLContextOnPause method to prevent GLSurfaceView from releasing context,

My minSdk is 7.  Preserving GL context is a hint.  You call it and pray it works.  See the official docs at http://developer.android.com/reference/android/opengl/GLSurfaceView.html#setPreserveEGLContextOnPause(boolean)

It's just works - EGL is only allowed to dispose context on power management events, OS may terminate application process if user navigate away but that's it. Anyway if you really want to play nice you can simply reaload everything when you catch EGL_CONTEXT_LOST.
 
 
if you are targeting older version simply back-port (or use one of existing back-ports eg. the one from Replica Island).

That's a solution with its own set of problems.  Check some of the comments in the RI version.  In fact, I highly doubt it would work well across the spectrum of today's Android hardware.
Why, current GLSurfaceView implementation is based on the one from RI. GLSurfaceView is just helper class, there is nothing HW specific (see: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/opengl/java/android/opengl/GLSurfaceView.java)
 

That being said multi-activity model is extremely unfit for games, I'm guessing that you are using some homebrew engine without  good UI toolkit hence you'd like to use PreferenceActivity - my advice is to adapt some existing widget toolkit (or part of it, if your game is in C++ there are bunch of options: cegui, gwen, librocket, twl, otk), as a stopgap you can simply show fullscreen dialog (Dialog class subclass) with preference like layout - that way your settings screen will not interfere with game activity lifecycle.

I agree it looks like it should be easy to make a Preference*Dialog* instead of PreferenceActivity.  And yet, apparently it's not. 
Not _PreferenceDialog_, simply create layout that look's like PreferenceActivity, do not try to host actual preferences infrastructure inside dialog since it's not designed to be used that way.

--
Bart
 

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment