title: runOnUiThread from class that doesn't support it
body: <p>I am editing this code from cSipSimple: <a href="https://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/src/com/csipsimple/ui/incall/InCallCard.java?spec=svn2170&amp;r=2170" rel="nofollow">https://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/src/com/csipsimple/ui/incall/InCallCard.java?spec=svn2170&amp;r=2170</a></p>
  
  <p>And wish to add this method:</p>
  
  <pre><code>public void pushtotalk2(final View view) {
  
          final boolean on = ((ToggleButton) view).isChecked();
          ((ToggleButton) view).setEnabled(false);
  
          new Thread(new Runnable() {
              @Override
  
  
      public void run() {
              try {
                  Instrumentation inst = new Instrumentation();
                  if (on) {
  
                      inst.sendKeyDownUpSync(KeyEvent.KEYCODE_NUMPAD_MULTIPLY);
                      Thread.sleep(500);
                      inst.sendKeyDownUpSync(KeyEvent.KEYCODE_9);
                      Thread.sleep(500);
  
                      runOnUiThread(new Runnable() {
                          public void run() {
                              ((ToggleButton) view).setBackgroundResource(R.drawable.btn_blue_glossy);
                              ((ToggleButton) view).setEnabled(true);
                          }
                      });
                  } else {
                      inst.sendKeyDownUpSync(KeyEvent.KEYCODE_POUND);
                      Thread.sleep(500);
                      inst.sendKeyDownUpSync(KeyEvent.KEYCODE_9);
                      Thread.sleep(500);
                      runOnUiThread(new Runnable() {
                          public void run() {
                              ((ToggleButton) view).setBackgroundResource(R.drawable.btn_lightblue_glossy);
                              ((ToggleButton) view).setEnabled(true);
                          }
                      });
                  }
              } catch (InterruptedException e) {
                  Log.d(TAG, "Failed to send keycodes: " + e.getMessage());
              }
          }
      }).start();
  }
  </code></pre>
  
  <p>However I get the error: <code>runOnUiThread(new Runnable(){}) is undefined for the type new Thread(){}</code></p>
  
  <p>My understanding is that the activity class has this method, but how do I access it from my code?</p>
  
  <p>I tried making a  constructor and got this error:</p>
  
  <p><code>Implicit super constructor FrameLayout() is undefined. Must explicitly invoke another constructor</code></p>
  
  <p>Any ideas on how this is done correctly?</p>