Android - 监控服务上的按键

标签 android service keypress onkeypress

我刚刚将服务集成到我的 Android 应用程序中 - 我也在使用 startForeground,因为它是一个关键应用程序。

因此,我的问题是 - 当用户在其通知面板中的通知/服务上按下按键后,我如何让它恢复到应用程序。我到处都在寻找这个,但在任何地方都找不到……如果服务没有被定向回 onKeyPress 应用程序,那么使用服务就没有多大意义,所以真的需要让它工作。

非常感谢任何帮助。

谢谢

最佳答案

So, my question is - how do I get it to revert the user to the application when they have done a keyPress on the notification / service in their Notification Panel.

如果用户点击通知面板中的条目(通过触摸屏或方向键),您通过 setLatestEventInfo() 提供的 PendingIntent 将被执行。使用适当的 PendingIntent 来调出您要查找的 Activity 。 Here is a sample application证明这一点。

关于Android - 监控服务上的按键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4913982/

相关文章:

Android:布局在 gridview 的底部(在它的末尾)

android - UI - 如何同时显示 GridView 和 Linear 布局

android - 如何制作一串不易碎的空格?

android - 尝试在 actionBarActivity 中启动 fragment

java - 以编程方式重新启动可作为 Windows 服务运行的 Java 应用程序

java - Jconsole 无法连接到作为 Windows 7 服务运行的 java 进程

php - 如何使用php web服务获取mysql数据库中的数据

JQuery Keydown、Keypress、Keycode 等

javascript - 如何处理原型(prototype)上的 "left"和 "right"键?

javascript - 将 JQuery 输入限制为仅先前未输入过的唯一字符的任何方法