I just created my own "Home" to replace the stock android one or Sense.
All is working fine and I get all I want. My only problem is to replace to long press on home key ( that usually show the last 6 activities you launched) by my own launcher.
I successfully replace the long press on MENU button with this code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//Log.i(TAG,"Keycode: "+keyCode);
if (keyCode == KeyEvent.KEYCODE_MENU) {
// this tells the framework to start tracking for
// a long press and eventual key up. it will only
// do so if this is the first down (not a repeat).
event.startTracking();
return true;
}
(...)
and this part part for the long press:
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
//Log.i(TAG,"LONG"+keyCode);
Toast.makeText(Launcher.this,"LONG "+keyCode, Toast.LENGTH_SHORT).show();
if (keyCode == KeyEvent.KEYCODE_MENU) {
(...)
But the problem is that I wasn't able to replace the KeyEvent.KEYCODE_MENU with KeyEvent.KEYCODE_HOME
is that something locked in the code that avoid user to use a Home long press?
Thank a lot for all the information you woulg give me.
Everything I have ever read states that this can't be done... Here is a post on Android Beginners where I asked a very similar question:
http://groups.google.com/group/android-beginners/browse_thread/thread/d8cdcd1c52d79ef1/0f4b184da6f248a9?lnk=gst&q=home+key#0f4b184da6f248a9
However, I have recently come across an app that successfully allows you to launch it by double-tapping the home key so there has got to be something that can be done. I looked into that approach for a while but couldn't get it to work. Now that I know someone else figured it out I'm going to take another stab at it....
EDIT While overriding a long-press of the home button cannot be done, I have found a way to successfully implement a double-press of the home button. The general idea for this is as follows:
Essentially, the home-replacement activity does nothing more than either launch the real home app specified by the user or launch your app... It never displays its own UI.
I have found that this works pretty well, and actually have an app published in the Android Market that does this. If you would like to see it in action, it is called "Quick Launch" and the publisher name is listed as "MagouyaWare"
Hope this helps!
You can register fake activity for the long press HOME button
by adding to manifest:
<intent-filter>
...
<action android:name="android.intent.action.ASSIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With