开发者

Android: using the same service in several activities

开发者 https://www.devze.com 2023-03-06 04:59 出处:网络
Is it common for several activities to use/share the same service? If so, what is the best way to do this? Does each activity need to bind to that service (i.e. each activity h开发者_运维问答as its ow

Is it common for several activities to use/share the same service? If so, what is the best way to do this? Does each activity need to bind to that service (i.e. each activity h开发者_运维问答as its own ServiceConnection object)

Thanks


Is it common for several activities to use/share the same service?

Yes, you can bind service from different activities. It's basically one of the reasons services were introduced.

Does each activity need to bind to that service?

Yes, you should treat each activity as independent part and that's why each activity should create it's own connection.

0

精彩评论

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