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

Android -- 使用广播监听Home键

时间:2014-12-21 18:04:54      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

//广播监听事件类

public class HomeKeyEventBroadCastReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        //do what you want
        System.exit(0);
    }
}

private HomeKeyEventBroadCastReceiver homeKeyEventReceiver;
protected void onResume() {
     super.onResume();

     //监听Home建
     homeKeyEventReceiver = new HomeKeyEventBroadCastReceiver();
     registerReceiver(homeKeyEventReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}

@Override
protected void onStop() {
    unregisterReceiver(homeKeyEventReceiver);
    super.onStop();
}


http://862123204-qq-com.iteye.com/blog/1888532

Android -- 使用广播监听Home键

标签:

原文地址:http://blog.csdn.net/tanmengwen/article/details/42061399

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