Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://developer.android.com/reference/android/view/View.html" rel="noreferrer">From the documentation of <code>View</code></a>:</p> <blockquote> <p><em>You must always be on the UI thread when calling any method on any view.</em> If you are doing work on other threads and want to update the state of a view from that thread, you should use a <code>Handler</code>.</p> </blockquote> <p>In your example, when you've to call the <code>dismiss()</code> method on the <code>ProgressDialog</code>, as per the above documentation, you must do so from the UI thread. The <code>messageHandler</code> is initialized to an instance of a <code>Handler</code> when the <code>HandlerThread</code> class is instantiated (presumably on the UI thread).</p> <p><a href="http://developer.android.com/reference/android/os/Handler.html" rel="noreferrer">From the documentation of <code>Handler</code></a>:</p> <blockquote> <p>Each <code>Handler</code> instance is associated with a single thread and that thread's message queue. When you create a new <code>Handler</code>, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.</p> </blockquote> <p>So to communicate with the UI thread from your new thread, just post a message to the <code>Handler</code> created on the UI thread.</p> <p>If you call methods on a <code>View</code> from outside the UI thread, it invokes <em>undefined behaviour</em>, which means, it <em>may appear</em> to work fine. But it's not <em>always</em> guaranteed to work fine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload