首页 > 移动平台 > 详细

Android开发中模拟Home键操作和关闭手机软键盘

时间:2015-06-01 18:55:25      阅读:238      评论:0      收藏:0      [点我收藏+]

1,在点击返回时,不想退出应用,直接模拟HOME键操作,可以写在onKeyDown事件中,也可以写在其它自己想要实现的地方:

                Intent intent = new Intent(Intent.ACTION_MAIN);
// 创建一个新的任务栈(这个必须要写)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_HOME);
this.startActivity(intent);

2,监听关闭手机软键盘:

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null && this.getCurrentFocus() != null) {
inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}

3,

Android开发中模拟Home键操作和关闭手机软键盘

原文:http://blog.csdn.net/true100/article/details/46312601

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!