用于理解 Android 概念的推荐资源
在相对轻松地完成简单的应用程序编码之后,我想更好地理解 Android 中各种概念组件之间的复杂关系。
更具体地说,我想了解什么是 Runnable,Looper 和 处理程序。
您可能会注意到,上述 3 个术语是 http://developer.android.com 中正式文档的链接,因此我的问题可能看起来很奇怪,所以让我解释一下:该文档对于已经了解 Android 中的工作原理的人来说可能是完美的,但我需要一些能够在以前的概念之上按顺序遍历基础知识的内容。
总而言之,我需要一些有关 Android 核心内部构建块的教程。你能推荐一个吗?
After a relatively easy coast to simple app coding, I would like to understand better the intricate relationships between various conceptual components in Android.
More specifically, I would like to understand what is Runnable, Looper and Handler.
As you may noticed, the above 3 terms are links to formal documentation in http://developer.android.com so my question may seem strange, so let me explain: That documentation may be perfect for someone who already understands how things work in Android, but I need something that sequentially walks through fundamentals, building on top of previous concepts.
To summarize, I need some sort of tutorial on core inner building blocks of Android. Can you recommend one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
详细的文章 Painless Threading 可能是您在 Android 上进行线程处理的最佳资源。
这个故事的寓意是,
AsyncTask
让多线程处理对您来说更容易。The detailed article Painless Threading is probably your best resource for threading on Android.
The moral of the story is that
AsyncTask
makes multithreading easier for you.Runnable 是一个核心 Java 接口——它表示可以运行的代码部分(通常由特定线程运行)。
Handler 是一个 Android 类,负责发布 Runnable\Message 以便特定线程运行或处理它们(以特定顺序)。
Looper 是保存 HandlerThread 将从中读取的 Runnable\Message 队列的结构。
Runnable is a core Java interface - it represents a code part that can be run (usually by a specific thread).
Handler is an Android class that is responsible for posting a Runnable\Message so that a particular thread will run or process them (in a specific order).
Looper is the structure that holds the Runnable\Message queue that a HandlerThread will read from.