Does this Run on the UI thread
Does this code actually run under the UI thread in android (2.2 & up). If not is there an example of how to do it.
In activity I call the JSInterface
class Xyz extends Activity implements OnInitListener () {
...
engine.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
}
final class DemoJavaScriptInterface {
DemoJavaScriptInterface() {
}
public void clickOnAndroid(final String num) {
runOnUiThread(new Runnable() {
public void run() {
if (isrunning) {
_tts.speak开发者_JAVA技巧(num,TextToSpeech.QUEUE_FLUSH, null);
}
}
});
}
If you're referring to the anonymous Runnable passed to runOnUiThread... yes, that will definitely run on the UI Thread as the method name suggests.
精彩评论