There are times when we need to run things through another thread, and have the returns (call backs etc) displayed on the UI. The UI thread cannot be manipulated from another thread, so the Android API has provided a number of ways to do this:
Activity.runOnUiThread:Â http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)
Example (in a call back function):
final MainAct hl = this; hl.runOnUiThread(new Runnable() { public void run() { hl.lblActivity.setText(hyp); hl.btnStartActivity.setEnabled(true); hl.btnSpeak.setEnabled(true); } });
View.post:Â http://developer.android.com/reference/android/view/View.html#post(java.lang.Runnable)