设为首页 加入收藏

TOP

Android消息处理系统
2014-11-24 07:54:09 来源: 作者: 【 】 浏览:1
Tags:Android 消息 理系统

制,Android消息循环是针对线程的(每个线程都可以有自己的消息队列和消息循环)。
下面根据如下列子来开始进行Android消息处理系统的分析。
package com.XXX;


import android.app.Activity;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.os.Handler;


public class MyHandler extends Activity {
static final String TAG = "Handler";
Handler h = new Handler(){
public void handleMessage (Message msg)
{
switch(msg.what)
{
case HANDLER_TEST:
Log.d(TAG, "Hanle Message in the handler thread, id = " + Thread.currentThread().getId() + "\n");
break;
}
}
};


static final int HANDLER_TEST = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "The main thread id = " + Thread.currentThread().getId() + "\n");


new myThread().start();
setContentView(R.layout.main);
}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android开机流程 下一篇Android分析之init.rc

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)