开发者

Android - binding both activity and widget to service

开发者 https://www.devze.com 2023-02-17 00:39 出处:网络
I need a way to bind, or connect, both an activity and a widget to a simple service that streams audio from a single online source. I can\'t for the life of me figure out how.

I need a way to bind, or connect, both an activity and a widget to a simple service that streams audio from a single online source. I can't for the life of me figure out how.

I also need the method I use to be able to return some value at least once a second to move a progress bar in the activity, but not the widget. Also, the service needs to开发者_如何学编程 keep playing in the background as it literally is a music/audio player.

I'm fairly new to Java, so please explain in more detail than to someone who knows what he's doing. Thanks.


I would recommend using a Broadcast Receiver in both your Activity and your Widget. Then broadcast from your service. This should be picked up by each and then you can handle them.

Same the otherway (to service) implement a Receiver and then broadcast from widget.

I think this should work and I am testing it now.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号