首页 > 代码库 > Android -- 使用广播监听Home键
Android -- 使用广播监听Home键
//广播监听事件类
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键
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。