开发者

Android: How to send back data from thread to service?

开发者 https://www.devze.com 2023-01-14 20:08 出处:网络
Hy! I have a service from which a start a new thread. This new thread wil开发者_Python百科l communicate with a TCP server using socket. What is the best way to send the data received from TCP server

Hy!

I have a service from which a start a new thread. This new thread wil开发者_Python百科l communicate with a TCP server using socket. What is the best way to send the data received from TCP server back to the service? Handlers or something else?

Thanks in advance, kukukk


It has been a while since this thread was opened, but I guess people are still coming here.
I managed to achieve this using the following answer:
How to communicate a service with a running thread in Android

Good luck ya' all.


What is the best way to send the data received from TCP server back to the service?

Make the thread be an inner class of the service, then just call a method on the service.

0

精彩评论

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