Android HOME键那些事
Posted 我辛飞翔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android HOME键那些事相关的知识,希望对你有一定的参考价值。
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));
转 http://blog.csdn.net/imyfriend/article/details/8293399
以上是关于Android HOME键那些事的主要内容,如果未能解决你的问题,请参考以下文章
Android 谈谈封装那些事 --BaseActivity 和 BaseFragment
Android谈谈封装那些事--BaseActivity和BaseFragment
从cocos2dx源代码看android和iOS跨平台那些事