开发者

How to use activity to request data from service?

开发者 https://www.devze.com 2023-02-17 09:22 出处:网络
Now, my program have an activity and a service. The serv开发者_运维知识库ice runs in the background and sometimes vibrates to ask users give some selection. I meet a problem here. I know broadcast cou

Now, my program have an activity and a service. The serv开发者_运维知识库ice runs in the background and sometimes vibrates to ask users give some selection. I meet a problem here. I know broadcast could pass data from service to activity. But if the activity is not working, then it cannot receive the broadcast information, so if user feels vibration but after a period of time start the activity then the activity will miss the broadcast information and cannot ask user to choose a selection. So does anybody know how to actively request the data from the service by activity? I just want when I onCreate() or onResume() the activity, my app could update UI in time?

Thanks


You can use Shared Preference for storing data... By using this you can access data throughout your application life cycle.

0

精彩评论

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