Activity、服务和通知的交互
我想启动一项将一些数据上传到网页的服务。该服务将通知发送到通知栏(更新进度栏)。到目前为止,一切都很好。 现在,我想在用户单击通知栏中的通知时显示一个活动。此活动应包含一个按钮和可选的上传状态,即我必须访问上传数据的服务。有没有正确的方法来处理这个要求?
该服务当前是从一个活动启动的。我想这里的主要问题是,将Notification中的pendingIntent
启动的Activity与服务“链接”起来,即访问服务信息。有人有该用例/问题的好例子吗?
I want to start a service that uploads some data to a web page. The service sends notifications to the notification bar (updates a progress bar). So far so good.
Now, I want to show a activity when the user clicks on the notification in the notification bar. This Activity shall contain a button and optionally a status of the upload, i.e. I have to access the service that uploads the data. Is there a correct way to handle this requirement?
The service is currently started from a activity. I guess the main problem here is, to "link" the activity that is started from the pendingIntent
on in the Notification with the service, i.e. access the service information. Does someone have a good example for that use case/issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将活动绑定到服务即可。希望这个,以及这个和这可以帮助您
Just bind the activity to the service. Hope this, and this and this helps you out