覆盖Home键长preSS在category.HOME活动preSS、Home、HOME、category

2023-09-12 21:50:31 作者:抽疯中,请勿扰

我刚刚创建了自己的家,以取代股票Android的一个或意义。

I just created my own "Home" to replace the stock android one or Sense.

所有工作正常,我把所有我想要的。我唯一​​的问题是,以取代对home键长preSS(通常表明你发起最后的6项活动),通过我自己的发射器。

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.

我成功地与此code替换MENU键长preSS:

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;
}
(...)

和这部分的部分为长preSS:

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) {
        (...)

但问题是,我是不是能够与KeyEvent.KEY code_HOME

But the problem is that I wasn't able to replace the KeyEvent.KEYCODE_MENU with KeyEvent.KEYCODE_HOME

是的东西锁在code能避免用户使用一个主场龙preSS?

is that something locked in the code that avoid user to use a Home long press?

感谢了很多为你woulg给我的信息。

Thank a lot for all the information you woulg give me.

推荐答案

一切我所读过的状态,这不能做......这是在Android入门后,我问了一个非常类似的问题:

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

不过,我最近遇到一个应用程序,成功地让你通过双击home键,以便出现了要的东西可以做,以启动它。我看着这个方法一段时间,但无法得到它的工作。现在我知道别人理解了它我会采取另一种刺吧......

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....

修改 虽然覆盖home键的长preSS不能做,我已经找到一种方法,以成功实施home键的双preSS。此总的想法是:

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:

请您的应用程序的行为作为一个家庭更换应用程序(看SDK样本中样品的家应用程序) 允许的方式在你的应用程序来指定主应用程序来使用(这是pretty的直白的present用户的家庭更换应用程序的列表) 在home键的第一preSS启动一个定时器。 如果定时器超时,启动家庭应用 如果用户presses家里键一秒钟计时器停止之前,启动应用程序

从本质上讲,家庭更换活动确实不外乎两种启动用户指定的真正的家应用程序或启动应用程序...它从来没有显示其自己的用户界面。

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.

我发现,这个工程pretty的好,居然有发表在Android市场,做一个这样的应用程序。如果你想看到它在行动上,它被称为快速启动和发布者的名称被列为MagouyaWare

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"

希望这有助于!