码迷,mamicode.com
首页 > 移动开发 > 详细

Android HOME键那些事

时间:2016-06-04 00:41:09      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

app中对于HOME键广播事件的接收
首先,自定义一个BroadcastReceiver:
class HomeKeyEventBroadCastReceiver extends BroadcastReceiver { static final String SYSTEM_REASON = "reason"; static final String SYSTEM_HOME_KEY = "homekey";//home key static final String SYSTEM_RECENT_APPS = "recentapps";//long home key @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) { String reason = intent.getStringExtra(SYSTEM_REASON); if (reason != null) { if (reason.equals(SYSTEM_HOME_KEY)) { // home key处理点 } else if (reason.equals(SYSTEM_RECENT_APPS)) { // long home key处理点 } } } } }

其次,生成且注册之

        receiver = new HomeKeyEventBroadCastReceiver();
        registerReceiver(receiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

Android HOME键那些事

 

转 http://blog.csdn.net/imyfriend/article/details/8293399

Android HOME键那些事

标签:

原文地址:http://www.cnblogs.com/622698abc/p/5557970.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!