You mentioned "crash" in your first post. So the screen is just black. That's weird because if the activity is really re-created from scratch then you should get the exact same result as in first start of your app.
I think you should make yourself familiar with the activity life cycle. The Android OS can finish your activities and kill your app any time it wants to. There are multiple reasons for that to happen, not only when the screen is locked. But by looking at your activity code I cannot see any problems there. I guess it's related to your "GameView" component. If your GameView does all the heavy lifting like loading graphics, maintaining game state, and perhaps creating OpenGL ES textures you need to notify it about the activity life cycle events onResume and onPause. If you're developing an OpenGL ES game you need to be aware that pausing the activity basically discards all OpenGL textures you may have created. That might be the real reason why your screen is black, not a restarted activity. On Wednesday, January 30, 2013 10:14:59 AM UTC-6, Davide Moriello wrote: > > No errors. When my app is launched (it's a game) and I lock the screen > (sleep?) and everything is black, the app start again calling a new > activity, creating a new istance of this class: > http://pastebin.com/j1mTRUnB > > I don't know why, I don't touch anything, it just create a new activity > when is sleeping. > > Il giorno mercoledì 30 gennaio 2013 17:06:43 UTC+1, Johan Appelgren ha > scritto: >> >> What error do you get? >> >> On Wednesday, January 30, 2013 11:48:59 AM UTC+1, Davide Moriello wrote: >>> >>> Hello, I'm developing an android app for some time now. Everything is >>> going well. When I close my app with the home button and I reopen it there >>> aren't any problems or crashes. >>> But, when I have my app open and I lock my screen the app create a new >>> istance of the activity and call again onCreate when the screen is >>> locked... so crash! >>> >>> the code of my activity is here >>> http://pastebin.com/j1mTRUnB >>> >>> >>> What can this be? Any suggestion? Thank you a lot =) >>> >> -- -- 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 --- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

