收藏官网首页
查看: 17188|回复: 2

[讨论] 发现 机智云自动生成 Android App 代码中的一处Bug

3

主题

6

帖子

80

积分

注册会员

Rank: 2

积分
80
跳转到指定楼层
楼主
发表于 2017-7-8 01:48:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
教您5分钟接入机智云,实现傻瓜式开发
Android 框架程序版本 :2.5.0.022212
SDK版本 : 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);
                        }
                }

3

主题

6

帖子

80

积分

注册会员

Rank: 2

积分
80
沙发
 楼主| 发表于 2017-7-18 15:19:48 | 只看该作者
正常运行时,未出现此bug, 联机调试时,可能会遇到
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

加入Q群 返回顶部

版权与免责声明 © 2006-2024 Gizwits IoT Technology Co., Ltd. ( 粤ICP备11090211号 )

快速回复 返回顶部 返回列表