???????Android?????????
???????????? ???????[ 2013/1/6 10:43:56 ] ????????
???????Windows??????????????Windows??????????????????????????????????????Android??ó?????????????????????????????????????????????????ο???Windows????????????????Android????????????????????Android???Looper??Handler????????????????Android???????????????(????????????????????????к???????)????????????????Android?????????????
????Android????Looper?????????????????к??????????????????ο?Looper????? ???????Loop.myLooper()??????????Looper???????Loop.getMainLooper()???????????????????Looper????
?????????Android??????????к??????????????????????????????????(?????????????)?????????к??????????(Looper)???????????????????????????????п???????????????????????????????????????????????????е??????????????????????к??????????????????????????Looper.prepare()????????????У???????Looper.loop()???????????????????????
????-----------------------------------------------------------------------
????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();
????}
????}
????----------------------------------------------------------------------------------------------------
??????????????????????????????????Handler?н???????????
????Activity?????UI????????????????У?Android??????????????Activity?????????????к???????(Looper)??????????ο?ActivityThread.java?????
????Handler?????????????????????(Looper)????????У????????????????????е??????????Handler??????????????Looper????????????????????????Looper??????????????ο?Looper?????
????Activity??Looper??Handler????????????:
???????Activity?п???????????????????????????????????Щ???????????????????????Activity?????????????У???????????????????д?????????????????????????2?????????Android???е?weget????????????????????????????????Android??????????Android????????????????????á?
?????????????????????????????????????????????????????Handle??????Handler????????????Looper?????????????Handler??sendMessage???????????????????ж????????????????????С??????????Handler??????е????handler??handleMessage??????????????
???????????漰????????????????ο??????????????Handler????????????
????1?????????MyHandler?????
????2????MyHandler.java?м??????μ????
????package com.simon;
????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?? "The handler thread id = " + Thread.currentThread().getId() + " ");
????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() + " ");
????new myThread().start();
????setContentView(R.layout.main);
????}
????class myThread extends Thread
????{
????public void run()
????{
????Message msg = new Message();
????msg.what = HANDLER_TEST;
????h.sendMessage(msg);
????Log.d(TAG?? "The worker thread id = " + Thread.currentThread().getId() + " ");
????}
????}
????}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11