Posts

Showing posts from 2012

Intercept HOME Key: Android

How to Intercept HOME Key in Android? The solution is: The prevailing wisdom says it cannot be done public static final int KEYCODE_HOME Key code constant: Home key. This key is handled by the framework and is never delivered to applications . Maybe the below code would work the way we want it to. But I don't think you can trap the Home key absolutely. Below method works for me. Hope this will work for you also.... Override below method in your activity.     @Override     public void onAttachedToWindow () {         super . onAttachedToWindow ();         this . getWindow (). setType ( WindowManager . LayoutParams . TYPE_KEYGUARD );               } After overriding above method, now you can easily listen HOME Key press in your activity using onKeyDown() method.     @Override     public boolean onKeyDown ( int keyCode , KeyEvent ev...