服务能否获得onBind期间活动的参考? [英] Can a service get a reference to the activity during onBind?

查看:104
本文介绍了服务能否获得onBind期间活动的参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本管理一个实例的MediaPlayer播放播客服务。一旦一个活动绑定到该服务就可以做的事情一样播放,暂停,停止等我用了一个服务,因为我想播客继续玩的活性被破坏后,即使

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.

推荐答案

该SDK API样本演示应用程序有一个服务的一个例子讯息传回的活动

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

这篇关于服务能否获得onBind期间活动的参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆