Android Error Cancelling event due to no window focus

给你一囗甜甜゛ 提交于 2019-12-24 07:39:36

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/38161298/android-error-cancelling-event-due-to-no-window-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!