我刚刚将服务集成到我的 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/