TabActivity和本地服务:如何消费每个选项卡中服务的数据?
我正在使用 Android TabActivity,如 TabLayout Demo 中所述。< br> 在每个选项卡中,我想以不同的方式显示应由 LocalService 收集的数据。
目前,只有一个选项卡活动消耗我的本地服务。我的所有选项卡活动(由意图调用)同步消耗数据的最佳方式是什么? (例如,一个选项卡活动应在 TextView 中显示数据,另一个选项卡活动应在地图上显示数据...)
感谢您的帮助!
I'm using Androids TabActivity as described in TabLayout Demo.
In each of these tabs I want to show data in a differently way which should be gathered by a LocalService.
Currently only one of the tab activities consumes my local service. What is the best way that all my tab activities (which are called by intents) consume the data synchronised?
(For example one tab activity should show the data in a TextView, an other should show the data on a map...)
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道已经太晚了,但是要解决这个问题,您可以尝试调用 getApplicationContext().bindService 而不仅仅是 bindService。
I know it's too late, but to solve this problem you can try call getApplicationContext().bindService instead of just bindService.
我现在通过将 LocalService 绑定到 TabActivity 解决了(?)我的问题。之后,我将服务静态化并通过在我的意图中调用公共方法来使用它。
这是“好代码”吗?
如果有人可以确认我的解决方案或给我一些提示以使其更好,我将不胜感激!
谢谢!
I have solved (?) my problem by binding my LocalService to the TabActivity now. After that I made the service static and use it by calling a public method in my intents.
Is this "good code"?
I would be very grateful if someone can confirm my solution or giving me some hints to make it better!
Thanks!