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處理點 } } } } }

其次,生成且註冊之app

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

Android HOME鍵那些事ide

 

轉 http://blog.csdn.net/imyfriend/article/details/8293399spa

相關文章
相關標籤/搜索