开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜