home键监听

来源:互联网 发布:xampp搭建php运行环境 编辑:程序博客网 时间:2024/05/19 10:09

http://blog.csdn.net/dany1202/archive/2011/06/14/6543769.aspx

 

 

注册:

 

view plaincopy to clipboardprint?
  1. IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);  
  2.         mCloseSystemDialogsReceiver = new CloseSystemDialogsIntentReceiver();  
  3.         registerReceiver(mCloseSystemDialogsReceiver, filter);  

 

监听:

 

view plaincopy to clipboardprint?
  1. private class CloseSystemDialogsIntentReceiver extends BroadcastReceiver {  
  2.         @Override  
  3.         public void onReceive(Context context, Intent intent) {       
  4.                       
  5.             String reason = intent.getStringExtra("reason");  
  6.             Log.d(TAG, "CloseSystemDialogsIntentReceiver reason is " + reason);  
  7.             if ("homekey".equals(reason)) {  
  8.                Log.d(TAG,"homekey click=========================");  
  9. //               EditWidget.this.finish();  
  10.                keyHomeFlag = true;  
  11.             }  
  12.              
  13.         }  
  14.     }  

 

原创粉丝点击