开发者

How to post results to a Handler in a different activity in Android?

开发者 https://www.devze.com 2023-02-12 06:16 出处:网络
I have an activity A that does some network I/O inside a thread. During that I/O, I want to be able to proceed to开发者_运维百科 a different activity B and get the results of that thread inside B. Is

I have an activity A that does some network I/O inside a thread. During that I/O, I want to be able to proceed to开发者_运维百科 a different activity B and get the results of that thread inside B. Is there a way to post to a Handler from A to B?


Are you instantiating B from A then you can pass the object of handler from from A to B and send messages to handler in A from B


You can post to a handler from anywhere you have an reference to it. So there are a ton of ways to do this. If you have a reference to the instance of A you can make an accessor or post methods or you can pass the handler instance around as you see fit.

0

精彩评论

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