Android处理程序-线程间通信 [英] Android Handlers - inter-thread communication

查看:52
本文介绍了Android处理程序-线程间通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Android中使用Handlers在两个线程之间实现双向通信?

How do you implement two-way communication between two threads with Handlers in Android?

我有一个生成线程B的服务A.从B到A的通信非常容易,只是将Handler传递给B的构造函数,但是如何从A到B呢? B没有自动为其分配任何Looper.

I have a Service A that spawns thread B. It's fairly easy to communicate from B to A, it's just to pass a Handler to the constructor of B, but how to do it from A to B? B does not have any Looper assigned to it automatically.

有没有人得到答案?

推荐答案

Here is good post explaining threads and communication using handlers. Also, the same blog has a number of posts regarding various thread constructs in Android

这篇关于Android处理程序-线程间通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆