偶发性的camera等应用的菜单键,后退键不起作用的问题

来源:互联网 发布:名著推荐 知乎 编辑:程序博客网 时间:2024/05/18 01:46

在某些低内存的设备上,会偶尔出现菜单键,后退键不起作用的问题,有很大的可能是因为输入法因为低内存被杀死了导致的,可以用如下方法修正。


--- a/core/java/android/view/ViewRootImpl.java 

+++ b/core/java/android/view/ViewRootImpl.java 
@@ -3647,7 +3647,7 @@ public final class ViewRootImpl implements ViewParent, 
if (result == InputMethodManager.DISPATCH_HANDLED) { 
return FINISH_HANDLED; 
} else if (result == InputMethodManager.DISPATCH_NOT_HANDLED) { 
- return FINISH_NOT_HANDLED; 
+ return FORWARD; 
} else { c
return DEFER; // callback will be invoked later 

-- 

Rease: 
InputMethodManager instance is not null, so imm is not null, but InputMethodManager.mCurMethod will be set to null when disable or kill IME. It's normal behavior, and this is not synchronization issue. Google return FINISH_NOT_HANDLED but then the next input stage doesn't have the chance to handle this event, and at last, after going through all input stages, this event will be dropped. So change FINISH_NOT_HANDLED to 
FORWARD is to make sure this keyevent can have chance to be processed by the next input stage when ime is disable or been killed(ime can easily be killed on low ram device).   
0 0
原创粉丝点击