title: Sending update/data from one thread to UI thread in Android
body: <p>Based on a button click, I have to do some processing that requires some time. So I decided to do this in a separate thread from the main UI thread.</p>
  
  <p>Now, based on the calculations in the separate thread, I call a function in the main class of UI thread from which this new thread was created. In this function, I update the UI. I was told  that this won't work as I need to call the main UI thread.</p>
  
  <p>Could someone please help me with this?</p>
  
  <pre><code>@Override
  public void onListItemClicked(int index, Map&lt;String, Object&gt; data) {
  
      new Thread(new Runnable() {
          @Override
          public void run() {
              // Issue command() on a separate thread
              wasCommandSuccess(command());
          }
      }).start();
  }
  
  
  private void wasCommandSuccess(boolean result){
      if (result == false){
          getUI(BasicUI.class).showAlert("Command failed!", "Unable to access");
      }
  }
  </code></pre>