随笔分类 -  Deep into Android

core...
摘要:【欢迎转载,但请注明出处】博客园:http://www.cnblogs.com/byirain/archive/2013/04/21/3031001.html你需要前面对Handler,Looper作了一些总结,阅读此篇前建议大家先看一下:1.android多线程与UI操作2.android之handler总结3.android之Looper什么关系那么Thread、Handler、Looper、MessageQueue、Message之间到底是个什么关系呢?请看下图: 所属关系图1.通过翻看源码可以看到在Looper中有一个ThreadLocal<Looper> sThreadL 阅读全文
posted @ 2013-04-21 12:21 g.hui 阅读(970) 评论(0) 推荐(1)
摘要:Looper是什么? 刚开始对Looper很迷惑,一直想不明白到底有啥作用,经过这几天的研究终于算是有点明白了。先看官方文档中的解释:Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, callprepare()in the thread that is to run the loop, and thenloop()to have it process messages until th. 阅读全文
posted @ 2013-04-20 11:20 g.hui 阅读(225) 评论(0) 推荐(0)
摘要:什么是Handler 官方文档中的说法是:一个Handler允许你发送或处理一个Message或Runnable对象。每个Handler实例都和一个单独的线程及此线程的消息队列关联。当你创建一个新的handler对象时它会绑定到那个创建它的线程及此线程的消息对列上。从这一点上来说,Handler会传递messages和runnables到与它关联的消息对列上,当它们出队时执行它们。 文档中说Handler可以用来发送Message或Runnable,其实发送的都是Message,我们可以查看Handler的源码,找到PostXXX()方法,可以发现这此方法最终都会调用sendMessage.. 阅读全文
posted @ 2013-04-19 15:58 g.hui 阅读(260) 评论(0) 推荐(0)