Android - 监控服务上的按键
我刚刚将服务集成到我的 Android 应用程序中 - 我还使用 startForeground 因为它是一个关键的应用程序。
所以,我的问题是 - 当用户在通知面板中的通知/服务上按下按键时,如何将其恢复到应用程序。我已经到处寻找这个,但在任何地方都找不到它......如果它们没有被定向回 onKeyPress 应用程序,那么使用服务就没有多大意义,所以真的需要让它工作。
非常感谢任何帮助。
谢谢
I have just integrated services into my android app - I am also using startForeground because it's a critical app.
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. I have looked everywhere for this and can't find it anywhere...There isn't much point in using services if they don't get directed back to the app onKeyPress so really need to get this working.
Any help is much appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果用户点击通知面板中的条目(通过触摸屏或方向键),您通过
setLatestEventInfo()
提供的PendingIntent
将被执行。使用适当的PendingIntent
来启动您寻求的活动。 这是一个示例应用程序演示了这一点。If the user clicks on the entry in the notification panel (via touchscreen or D-pad), the
PendingIntent
you supplied viasetLatestEventInfo()
will be executed. Use an appropriatePendingIntent
to bring up the activity you seek. Here is a sample application demonstrating this.