Android中的Looper对象详细介绍
2014-02-13 16:32
806 查看
Java 官网对Looper对象的说明:
public class Looperextends Object
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, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped.
Most interaction with a message loop is through the Handler class.
This is a typical example of the implementation of a Looper thread, using the separation of prepare() and loop() to create an initial Handler to communicate with the Looper.
复制代码 代码如下:class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
}
};
Looper.loop();
}
}
主要方法:
static void loop() : Run the message queue in this thread.
static void prepare() : Initialize the current thread as a looper.
您可能感兴趣的文章:
相关文章推荐
- Android 通过Intent使用Bundle传递对象详细介绍
- Android消息机制(Handler、MessageQueue、Looper)详细介绍
- android之Looper详解及api详细介绍,使用案例
- android Looper类介绍
- Android-Looper类介绍
- Android增量升级的方法和原理详细介绍
- iOS 对象属性详细介绍
- Android ImageView 的scaletype属性详细介绍
- [转]android editText属性详细介绍
- android之Service介绍之三 AIDL与传递对象
- JSP内置对象详细介绍(上)
- android 菜单的详细介绍
- linux系统不同对象升级方法详细介绍
- Android游戏开发之数据库SQLite 详细介绍(十七)
- 详细介绍Android中Parcelable的原理和使用方法
- JSP九大内置对象详细介绍
- android rom制作之bootimg的详细介绍和使用
- Android手机信号强度检测详细介绍
- android listview优化几种写法详细介绍
- Android Bitmap详细介绍