是否有一个onBack pressed()替代服务?有一个、onBack、pressed

由网友(白栀i)分享简介:我知道,服务无法实现返回键preSS和我理解的理由。但有一个应用的工具条(上Play商店),其反应返回键presses。它是增加了一个视图系统覆盖并删除时,返回键为pressed视图的服务。任何人都可以解释这是如何实现的?I know that services cannot implement Back key p...

我知道,服务无法实现返回键preSS和我理解的理由。但有一个应用的工具条(上Play商店),其反应返回键presses。它是增加了一个视图系统覆盖并删除时,返回键为pressed视图的服务。任何人都可以解释这是如何实现的?

I know that services cannot implement Back key press and I understand the rationale. But there is an app called SideBar (on Play Store) that reacts to back key presses. It is a service that adds a view as system overlay and removes the view when the back key is pressed. Can anybody explain how this is done?

下面是另一个应用,做它做好。我已经走遍了网络,但还没有找到一个解决这个问题。任何想法?

Here is another app that does it well. I have scoured the web, but have not found a solution to this problem. Any ideas?

推荐答案

的的在这里的 是很好的例子,addview的服务,你也可以使用监听器,如果你想在服务。

here is nice example to addview in Service and also you can use listeners if you want in services.

我也在寻找服务听众执行,终于找到了。

i was also looking for the listeners implementation in service and finally found it.

记得加权限

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

和增加服务类

<application>
.
 .
  <service android:name=".YourServiceClass"></service>
 .
.
</application>

在AndroidManifest.xml中。

in AndroidManifest.xml.

阅读全文

相关推荐

最新文章