zoukankan      html  css  js  c++  java
  • android 监听Home键

    /**
     * Home 键监听,当按下Home键时,系统会发出action为Intent.ACTION_CLOSE_SYSTEM_DIALOGS的BroadcastReceiver
     * 在程序里动态注册监听,即可达到监听Home键的效果
     */
    public class InnerReceiver extends BroadcastReceiver {

        final String SYSTEM_DIALOG_REASON_KEY = "reason";
        final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
        final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";

        @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_DIALOG_REASON_KEY);
                if (reason != null) {
                    Log.e("TAB", "action:" + action + ",reason:" + reason);
                    if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
                        // 短按home键
                        Log.e("TAB", "home key down....");
                    } else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
                        // 长按home键
                        Log.e("TAB", "home long key down...");
                    }
                }
            }
        }

    }

  • 相关阅读:
    众包中使用变分推断和信念传播的几篇文章
    众包中的概率图模型和 EM 算法的使用和总结
    矩阵求导
    CCDM2018会议见闻
    关于 PCA 算法的一点小结
    Nginx--安装
    Nginx--简介
    linux--系统启动过程
    linux--目录结构
    Linux 远程连接工具Xshell6
  • 原文地址:https://www.cnblogs.com/lianghui66/p/3222735.html
Copyright © 2011-2022 走看看