android runonuithread()函数没有执行

Moh*_*wal 6 android

我正在开发一个使用名为flite的第三方tts的应用程序.我正在做一些像tts说句子的事情.我想突出显示每个单词.为此,我设法从tts获得了单词级回调.工作流程是这样的 - 按下"说文本"按钮.它启动tt服务,然后将文本发送到使用C语言的flite tts并与应用程序结合.现在,从C代码开始,在每个单词之后我对两个不同的java活动进行两次回调:一个到tts服务,将第二个单词说成我的测试java活动以突出显示该单词.我在测试活动中成功获得了单词级回调,但之后我无法进行任何UI工作.

以下是我收到回调时执行的代码:这是从C代码调用的函数.

private void WordCallback(int isword) {// from
    // callback
    if (isword == -1) {
        Log.d(LOG_TAG, "its not a word");
    } else if (isword == -2) {
        Log.d(LOG_TAG, "yeah..its the end");
    } else {
        Log.d(LOG_TAG, "its word no " + isword);

        int word = isword;
        Log.d(LOG_TAG, "highlightwords");
        highlightwords(isword);

        if (isword == 4) {
            Log.d(LOG_TAG, "in if");

            new Thread(new Runnable() {
                @Override
                public void run() {
                    Log.d(LOG_TAG, "thread started");
                    try {
                        Flitetest.this.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Log.d(LOG_TAG, "run on ui");
                                textview.setText("#" + isword);
                            }
                        });
                        Thread.sleep(300);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    }    
}
Run Code Online (Sandbox Code Playgroud)

FliteTest是活动的名称.日志打印到"线程已启动",但runonuithread()内的代码永远不会执行,也没有错误.

另外,如果textview.settext("something")没有线程和runonuithread()写入,它会给出错误:

fatal signal 11(sigsegv) at 0x6fc64e87(code=1), thread 20292(SynthThread).

这种行为的原因是什么?

No_*_*ulz 0

在 Android 上ICS (4.0+),如果您的android:anyDensity=false,AndroidManifest.xml并且 已在 ICS 手机上强制启用 GPU 渲染。对于原生 Android 应用程序来说,这也是一个问题。您可以选择不使用这些android:anyDensity=false选项,或者禁用手机上的强制 GPU 渲染。由于您无法在其他人的手机上真正控制后者,因此前者似乎是最好的解决方案。dp请记住在所有then 上使用 ' ' 后缀dimensions