Android的重写home键 [英] Android Overriding home key

查看:642
本文介绍了Android的重写home键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这个问题表明我知道我们不能覆盖Home键事件,但如果你进入的仿真器的的Andr​​oid 2.2 ,你会看到一个应用程序的汽车首页它已经覆盖最像家的钥匙,结束通话。

As the question suggests I know we can't override the Home key event but if you look into the emulator of android 2.2 you will see an application Car Home it has overridden most of the keys like Home, end call.

现在,该点是它们又是怎样做的呢?我试图窥视到应用程序的源$ C ​​$ C,但让我吃惊的不可用,或者我无法找到它,但我不认为以后是这样。

Now, the point is how have they done it? I tried to peep into the source code of the app but to my surprise its not available or I am unable to find it, but I don't think later is the case.

推荐答案

我同意 @Romain盖伊

您不能覆盖​​的home键的行为。

You can't override the behaviour of home button.

什么汽车首页应用程序的作用:它定义本身作为一个发射器。您还可以定义你作为一个发射台,它将得到通知时,主屏幕是即将上马。

What the Car Home app does: it has defined itself as a launcher. You can also define yours as a launcher, and it will be notified when the home screen is about to be launched.

检查了这一点:<一href="http://developer.android.com/reference/android/content/Intent.html#CATEGORY_LAUNCHER">Intent.html#CATEGORY_LAUNCHER

请注意,这并不意味着您的应用程序/活动通知时,home键是pssed,以便它可以覆盖它的行为$ P $,但被告知,当系统即将推出的主屏幕。两者是不同的东西。在这种类型的通知,机器人已经派出了应用程序(这是目前执行),以冻结状态,而且不会有过发生了什么任何控制。

Please note that this doesn't mean that your app/activity is notified when the home button is pressed so that it can override the behaviour of it, but is notified when the system is about to launch the Home Screen. Both are different things. in this type of notification, Android already has sent the app (Which is currently executing) to the frozen state, and it won't have any control over what's happening.

这是据我所知。我猜 @Romain盖伊可以纠正我,如果我错了,在任何地方。

This is as far as I know. I guess @Romain Guy may correct me if I am wrong at any place.

这篇关于Android的重写home键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆