Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:26:39+00:00 2026-06-16T06:26:39+00:00

Can anyone tell me if there’s any difference between using runOnUiThread() versus Looper.getMainLooper().post() to

  • 0

Can anyone tell me if there’s any difference between using runOnUiThread() versus Looper.getMainLooper().post() to execute a task on the UI thread in Android??

The only thing I can determine is that since runOnUiThread is a non-static Activity method, Looper.getMainLooper().post() is more convenient when you need to code something in a class that can’t see the Activity (such as an interface).

I’m not looking for a discussion on WHETHER something should be executed on the UI thread, I get that some things can’t and a great many things shouldn’t, however, some things (like starting up an AsyncTask) MUST be executed from the UI thread.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:26:40+00:00Added an answer on June 16, 2026 at 6:26 am

    The following behaves the same when called from background threads:

    • using Looper.getMainLooper()

      Runnable task = getTask();
      new Handler(Looper.getMainLooper()).post(task);
      
    • using Activity#runOnUiThread()

      Runnable task = getTask();
      runOnUiThread(task);
      

    The only difference is when you do that from the UI thread since

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

    will check if the current Thread is already the UI thread and then execute it directly. Posting it as a message will delay the execution until you return from the current UI-thread method.

    There is also a third way to execute a Runnable on the UI thread which would be View#post(Runnable) – this one will always post the message even when called from the UI thread. That is useful since that will ensure that the View has been properly constructed and has a layout before the code is executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question 1 Can anyone tell me if there is any difference between following 2
Can anyone please tell me is there any special requirement to use either EXTERN
can anyone tell me if there is any alternative for visual asssit? We are
Can anyone tell me if there is any performance benefit to assigning an object
Can anyone tell me what is the difference between base and recommended packages. If
Can anyone please tell me if there is any way we can find out
I can get particular validator using Page.Validators[0] Can anyone tell me is there a
Can anyone tell me if there is limited SQL support using unixODBC drivers on
Can anyone tell me if there is a way to select a video from
Can anyone tell me what is causing the space below the images? There seems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.