开发者

Android How to pass real time data up the stack from local service to the activity?

开发者 https://www.devze.com 2023-04-09 07:14 出处:网络
I have a local service that will need to wait for a response and when it gets the response immediately update the activity with that information.So the activity will not poll a service method but the

I have a local service that will need to wait for a response and when it gets the response immediately update the activity with that information. So the activity will not poll a service method but the moment the local service gets some data it has to inform that activity immediately somehow.

So Activity--binds-->LocalService <------>(RemoteService separate process). So I know I could just package it up in an intent and pass it up to the activity ... but is that the best/only option. How else might one communicate up the stack from the local service to the activity thats invoking the local service? Keep in mind I already have the local service binding to a 开发者_开发技巧remote separate process service which runs forever in the background and periodically sends realtime data to the local service. Thanks


you can pass the handler object of the activity to service thru setter() and using this object you can update the change in the activity.

0

精彩评论

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