Android开发中Looper.prepare()和Looper.loop()

  public void handleMessage(Message msg) {

  if (DEBUG_MESSAGES) Slog.v(TAG, ">>> handling: " + codeToString(msg.what));

  switch (msg.what) {

  case LAUNCH_ACTIVITY: {

  Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityStart");

  final ActivityClientRecord r = (ActivityClientRecord) msg.obj;

  r.packageInfo = getPackageInfoNoCheck(r.activityInfo.applicationInfo, r.compatInfo);

  handleLaunchActivity(r, null);

  Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

  }

  break;

  case RELAUNCH_ACTIVITY: {

  Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityRestart");

  ActivityClientRecord r = (ActivityClientRecord) msg.obj;

  handleRelaunchActivity(r);

  Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

  }

  break;

  case PAUSE_ACTIVITY:

  Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityPause");

  handlePauseActivity((IBinder) msg.obj, false, (msg.arg1 & 1) != 0, msg.arg2, (msg.arg1 & 2) != 0);

  maybeSnapshot();

  Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

  break;

  case PAUSE_ACTIVITY_FINISHING:

  Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityPause");

  handlePauseActivity((IBinder) msg.obj, true, (msg.arg1 & 1) != 0, msg.arg2, (msg.arg1 & 1) != 0);

  Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

  break;

  ...........

  }

  }