首页 > 移动平台 > 详细

Android -- 使用广播监听Home键

时间:2014-12-21 18:03:45      阅读:251      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!