[java]
protected void done() { Message message; Result result = null; // 发送消息Tag和 消息处理结果。消息处理结果又用AsyncTaskResult类封装起来,实例化对象传递进去的result就是上面doInBackground方法执行后的结果。 message = sHandler.obtainMessage(MESSAGE_POST_RESULT, new AsyncTaskResult<Result>(AsyncTask.this, result)); message.sendToTarget(); } step 4: 根据step 3,很明显 handler发送,后紧接着就是消息的处理
[java]
private static class InternalHandler extends Handler { @Override public void handleMessage(Message msg) { AsyncTaskResult result = (AsyncTaskResult) msg.obj; switch (msg.what) { case MESSAGE_POST_RESULT://通过step 3的Tag,执行改方法; // There is only one result result.mTask.finish(result.mData[0]); break; case MESSAGE_POST_PROGRESS: result.mTask.onProgressUpdate(result.mData); break; case MESSAGE_POST_CANCEL: result.mTask.onCancelled(); break; } } } step 5: 根据step 4执行 result.mTask.finish