I wouldn't count on the screen off broadcast being delivered at some useful
different timing from onPause().  These are both part of the flow of turning
off the screen, they will happen pretty much at the same time.

On Sun, Nov 29, 2009 at 3:46 AM, David Given <[email protected]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dianne Hackborn wrote:
> > Also you definitely do get paused when the screen is turning off, so you
> > really should be able to fix things by doing whatever you need to there.
>
> What I'm trying to do is to work around bug 3755:
>
> http://code.google.com/p/android/issues/detail?id=3755
>
> OpenGL apps don't get notified of surface destruction when the screen
> turns off, which means they try to render onto an invalid surface, which
> means the GL system gets itself knotted up and shifts into a state where
> it won't work any more.
>
> We do get onPause() when the screen turns off, but unfortunately it's
> sometimes too late (there appears to be a race between surface
> destruction and the onPause() being delivered). It just so happens that
> with apps using GLSurfaceView this mostly works, and with our app (which
> doesn't use GLSurfaceView) it mostly doesn't work!
>
> Testing for ACTION_SCREEN_OFF is a reasonable workaround --- it allows
> me to distinguish between the application being paused because it's
> being backgrounded (which works correctly) and the application being
> paused because the screen's being turned off (which doesn't); but
> because it's arriving after the onPause(), it's still arriving after
> surface destruction, which means it's too late to save the app, so all I
> can really do is quit. But that's way better than crashing --- thanks!
>
> (What I'd really like to do is to be able to detect the screen turning
> off *before* it actually does so, so I can switch to a different
> activity and therefore artifically force a paused-due-to-backgrounding
> event. Unfortunately I don't think any such event gets delivered.)
>
> - --
> ┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
> │
> │ "Under communism, man exploits man. Under capitalism, it's just the
> │ opposite." --- John Kenneth Galbrith
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iD8DBQFLEl8rf9E0noFvlzgRAlPRAKCjegDGvhGmko4osetZnWvMddp0mwCgnKNX
> a8v790x7bO1nr/utrZRnFHY=
> =Y/He
> -----END PGP SIGNATURE-----
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to