Activity # runOnUiThread 与 View # post

There is no real difference, except that the View.post is helpful when you don't have a direct access to the activity.

 

    public boolean post(Runnable action) {
       Handler handler;
        if (mAttachInfo != null) {
           handler = mAttachInfo.mHandler;
      } else {
            // Assume that post will succeed later
           ViewRoot.getRunQueue().post(action);
           return true;
        }

        return handler.post(action);
    }

 

 

    public final void runOnUiThread(Runnable action) {
        if (Thread.currentThread() != mUiThread) {
            mHandler.post(action);
        } else {
            action.run();
        }
    }

 

posted @ 2014-05-21 16:25  等风来。。  Views(301)  Comments(0)    收藏  举报
------------------------------------------------------------------------------------------------------------ --------------- 欢迎联系 x.guan.ling@gmail.com--------------- ------------------------------------------------------------------------------------------------------------