Home Key events are processed by PhoneWindowManager, that's to say consumed by Android system. That's why your activity can not see it.
BRs Guobin On Feb 9, 11:25 pm, Alex Feldman <alexfeld...@gmail.com> wrote: > I am trying to capture my activity to handle HOME button press with a > receiver programmatically, but the event is not firing. I can, > however, successfully register and capture this intent filter if I > declare it in a manifest.xml activity section. Here's the code for > the receiver: > > /////////////////////////////////////////// > > BroadcastReceiver br; > > br = new BroadcastReceiver() { > @Override > public void onReceive(Context context, Intent intent) { > return; // I put a breakpoint here to see if this gets called > } > > }; > > IntentFilter intf = new IntentFilter(); > intf.addAction(Intent.ACTION_MAIN); > intf.addCategory(Intent.CATEGORY_HOME); > intf.addCategory(Intent.CATEGORY_DEFAULT); > > registerReceiver(br, intf); > > /////////////////////////////////////////// > > Does anyone know why this doesn't capture the home button click? > > By the way, I tried working around this by creating another activity > and specifying its intent filter in the manifest. I set the activity > enabled="false" in the manifest but I couldn't figure out how to > enable that activity at run time. Bottom line, I only want to > register the home button intent filter for my application only when my > application is running, and I can't figure out how to do that. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en