Which method runs code on the UI thread from a background thread inside an activity?

  1. runInBackground
  2. Thread.sleep()
  3. runOnUiThread
  4. startService()
Answer

C) runOnUiThread

runOnUiThread posts the block to the main thread.

Computer Science MCQ · More Threading and Publishing Android Applications MCQs · Practise