Friday, January 25, 2013

Android: Solution to catch that the Home button was pressed

Home Button is like an emergency escape button.
Pressing Home twice will always take a user back to the center panel of the Home Screen, so whatever application they're running, it's easy for a user to get back to somewhere they know. You shouldn't really be overriding this unless you're producing a full Home replacement.

Don't  permanently override the Home button without the user confirming it.

We need to do follow three steps here...
1. Override onKeyDown and compare keycode with KeyEvent.KEYCODE_HOME
2. Override onAttachedToWindow()
3. add category to the activity because
CATEGORY_HOME : This is the home activity, that is the first activity that is displayed when the device boots.
<category android:name="android.intent.category.HOME"/>

Solution:  Source Code Here

Friday, January 11, 2013

Eclipse Widows 7: cntrl+space is not working

In windows 7, eclipse content assist (ctrl + space) is not working.

In Windows 7, "CTRL+Space" is used to switch the language. So its overriding the key of eclipse.

 1.       Windows key+R, type regedit and click Ok.
2.       Navigate to HKEY_CURRENT_USER/Control Panel/Input Method/Hot Keys 
3.       Select the key named: 
4.       00000070 and 00000010
o    Key Modifiers designate  (02c00000).
o    Virtual Key designates (20000000).
5.       In the right sub-window, there are three subkeys.
6.       Change the first byte in Key Modifiers from 02 to 00
7.       Change the first byte in Virtual Key from 20 to FF
8.       Log off and log back on.
9.       Do not change the Hot keys for input languages in Control Panel, unless you want to do this all over again.