发现 机智云自动生成 Android App 代码中的一处Bug
Android 框架程序版本 :2.5.0.022212SDK版本 : 2.06.06.11617
Bug 所在文件 : GosControlModuleBaseActivity.java
Bug 所在方法 : protected void hideKeyBoard()
出现 Bug的代码语句 : ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(GosControlModuleBaseActivity.this.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
原因 : GosControlModuleBaseActivity.this.getCurrentFocus() 可能返回 null
建议 使用 try ... catch 包含此代码 或使用 更稳妥的判断代码,如:
protected void hideKeyBoard() {
if(getSystemService(INPUT_METHOD_SERVICE) != null)
{
InputMethodManager im = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
if(GosControlModuleBaseActivity.this.getCurrentFocus() != null)
{
im.hideSoftInputFromWindow(GosControlModuleBaseActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
} 正常运行时,未出现此bug, 联机调试时,可能会遇到 厉害!!!
页:
[1]