Can a service get a reference to the activity during onBind?

微笑、不失礼 提交于 2020-01-04 06:07:21

问题


I have a service that basically manages a MediaPlayer instance for playing podcasts. Once an activity binds to the service it can do things like play, pause, stop, etc. I used a service because I want the podcast to continue playing even after the activity is destroyed.

I'd like the service to be able to send messages back to the activity in case of an error or for normal status updates. Is it possible for the service to get a reference to the activity that's trying to bind to it? Doesn't look like the intent makes this available.


回答1:


The SDK samples API Demos app has an example of a service that messages back to an activity



来源:https://stackoverflow.com/questions/4320012/can-a-service-get-a-reference-to-the-activity-during-onbind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!