当前位置: 动力学知识库 > 问答 > 编程问答 >

Android Error Cancelling event due to no window focus

问题描述:

I am learning Android, and trying to make multi screen app to get better at it. I have 3 activities.

1) Main

2) Game

3) GameOver

Main has game button, when pressed starts intent for the Game Activity. And after timer finishes in Game, I pass score variables to GameOver Activity over intent.

This flow works fine. But when I press back button after I see results in GameOver activit, the app minimizes. When I unMinimize the app it shows the Main activity screen (which actually want, but without app getting minimized). I am using finish() in Game activity where I am calling intent for GameOver.

In logs, I am getting following errors:

D/OpenGLRenderer: endAllActiveAnimators on 0xb7d6e128 (RippleDrawable) with handle 0xb7877690

W/ViewRootImpl: Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x68, repeatCount=0, eventTime=292244107, downTime=292244100, deviceId=-1, source=0x101 }

I created a test app to resolve/understand this issue having 3 activities and same flow. It is working find in that basic activity app. But not in my main app. I searched and found that its not an error. That's okay but I don't want my app to get minimized when back button is pressed. Any help?

网友答案:

Remove finish() from MainActivity. (If you have one at the intent where you call for Game Activity.)

分享给朋友:
您可能感兴趣的文章:
随机阅读: