Im not sure you can catch it from turning off, but you can setup a broadcast receiver to let you know when that happens.
Your receiver must be defined in java (not xml) and look for the ACTION_SCREEN_OFF broadcast. Hope that helps, theSmith On Nov 27, 6:47 am, David Given <[email protected]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Is there any way where I can detect that the screen is about to turn > off, so I can do some work *before* it happens? > > I need this to work around bug 3755: OpenGL apps sometimes crash when > the screen gets turned off because they don't get > surfaceDestroyed()/surfaceCreated() events. > > http://code.google.com/p/android/issues/detail?id=3755 > > Simply put, I need to shut down OpenGL before the phone has a chance to > detach the GPU. The only events I seems to be getting when the screen > turns off are onPause() and onWindowFocusChanged()... both of which turn > up *after* the GPU detaches, by which time it's too late. > > Can anyone suggest any way of doing this? > > (In desperation, I have tried to intercept the power key, but the > power/hangup key is treated specially and doesn't generate keyboard > events...) > > - -- > ┌─── dg@cowlark.com ─────http://www.cowlark.com───── > │ > │ "Sufficiently advanced incompetence is indistinguishable from > │ malice." -- Vernon Schryver > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org > > iEYEARECAAYFAksPvFIACgkQf9E0noFvlzioGACfW5r72xNXqykHvSu4SocKo0bw > rlkAoLNa6NZiWgczIBHtLmgJmzFZLiaR > =HOwY > -----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] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

