开发者

Does this Run on the UI thread

开发者 https://www.devze.com 2023-03-15 02:10 出处:网络
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.

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

精彩评论

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