我定义了软BACK按键,在正常情况下,点击返回都没问题,当有对话框弹出时,就会导致卡死,应用关闭
会不会是因为focus的问题引起的?
KeyEvent down = new KeyEvent(now, now, KeyEvent.ACTION_DOWN,eventCode, 0);
(IWindowManager.Stub.asInterface(ServiceManager.getService("window"))).injectKeyEvent(down, true);
KeyEvent up = new KeyEvent(now, now, KeyEvent.ACTION_UP,eventCode, 0);
(IWindowManager.Stub.asInterface(ServiceManager.getService("window"))).injectKeyEvent(up, true);
------解决方案--------------------
如果是AlertDialog或者Dialog对话框,检查一下有没有可能是对话框在处理返回或者关闭事件时的代码出问题。