1

我正在尝试使用以下代码检查 TTS 设施和语音设施的存在,但它因 starnge 错误而失败。我无法解决这个问题。我附上了 logcat 以供参考。请协助。

Java 代码:

private void checkTTSAvailability() {
    Log.i("Splash", "checkTTSAvailability"); 
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(checkIntent, 1);
}



protected void onActivityResult(int requestCode, int resultCode, Intent data) {    
    Log.i("Splash", "onActivityResult");
    if (requestCode == 1) {        

        Log.i("Splash", "onActivityResult - 1");
        if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {            
            // success, create the TTS instance     
            Log.i("Splash", "TTS check intent - success, : TTS presence confirrmed !");
            startDragAndDrop();
            } 
        else {            // missing data, install it   
                PackageManager pm = getPackageManager();
                Intent installIntent = new Intent();
                installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                ResolveInfo resolveInfo = pm.resolveActivity(installIntent, PackageManager.MATCH_DEFAULT_ONLY); 
                if (resolveInfo == null) {
                    Log.i("DragDrop", "No voice support on your phone"); 
                    Dialog d = new Dialog(this);
                    d.setTitle("Alert  ");
                    TextView tv = new TextView(this);
                    tv.setText("No voice support on your phone");
                    d.setContentView(tv);
                    d.show();  
                } else {
                    Dialog d = new Dialog(this);
                    d.setTitle("Alert  ");
                    TextView tv = new TextView(this);
                    tv.setText("Installing");
                    d.setContentView(tv);
                    d.show();
                    Log.i("DragDrop", "Installing");
                    startActivity(installIntent);
                }      
            }    
    } 
}

}

日志猫:

05-25 23:17:23.209: W/InputManagerService(271): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2bf51a78
05-25 23:17:23.209: D/PhoneStatusBar(355): disable: < expand icons alerts ticker system_info back* home* recent clock* >
05-25 23:17:24.049: I/ActivityManager(271): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.funandlearn/.Splash bnds=[80,150][160,250]} from pid 471
05-25 23:17:24.119: I/InputReader(271): Reconfiguring input devices.  changes=0x00000004
05-25 23:17:24.119: I/InputReader(271): Device reconfigured: id=8, name='cyttsp-spi', surface size is now 320x480, mode is 1
05-25 23:17:24.119: I/InputReader(271): Device reconfigured: id=9, name='atdaemon', surface size is now 320x480, mode is 3
05-25 23:17:24.139: I/ActivityManager(271): Config changed: {1.0 404mcc41mnc en_IN layoutdir=0 sw320dp w480dp h295dp nrml land finger -keyb/v/h -nav/h theme=ComponentInfo{com.sonyericsson.defaultruntimethemes/com.sonyericsson.defaultruntimethemes.BlackThemeService} s.451}
05-25 23:17:24.159: D/GestureDetector(431): touchSlop:23 doubleTapSlop:130
05-25 23:17:24.229: I/Splash(23437): checkTTSAvailability
05-25 23:17:24.249: I/ActivityManager(271): START {act=android.speech.tts.engine.CHECK_TTS_DATA cmp=com.svox.pico/.CheckVoiceData} from pid 23437
05-25 23:17:24.359: D/dalvikvm(23437): GC_EXPLICIT freed 26K, 35% free 8217K/12487K, paused 2ms+2ms
05-25 23:17:24.399: I/InputReader(271): Reconfiguring input devices.  changes=0x00000004
05-25 23:17:24.399: I/InputReader(271): Device reconfigured: id=8, name='cyttsp-spi', surface size is now 320x480, mode is 1
05-25 23:17:24.399: I/InputReader(271): Device reconfigured: id=9, name='atdaemon', surface size is now 320x480, mode is 3
05-25 23:17:24.409: I/ActivityManager(271): Config changed: {1.0 404mcc41mnc en_IN layoutdir=0 sw320dp w320dp h455dp nrml port finger -keyb/v/h -nav/h theme=ComponentInfo{com.sonyericsson.defaultruntimethemes/com.sonyericsson.defaultruntimethemes.BlackThemeService} s.452}
05-25 23:17:24.439: D/dalvikvm(355): GC_CONCURRENT freed 449K, 40% free 7410K/12231K, paused 2ms+13ms
05-25 23:17:24.459: D/GestureDetector(431): touchSlop:23 doubleTapSlop:130
05-25 23:17:24.579: D/dalvikvm(431): GC_CONCURRENT freed 471K, 18% free 7181K/8711K, paused 2ms+3ms
05-25 23:17:24.779: E/WindowManager(271): Window Session Crash
05-25 23:17:24.779: E/WindowManager(271): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@2c02b768 does not exist
05-25 23:17:24.779: E/WindowManager(271): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7165)
05-25 23:17:24.779: E/WindowManager(271): at com.android.server.wm.Session.setWallpaperPosition(Session.java:360)
05-25 23:17:24.779: E/WindowManager(271): at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:419)
05-25 23:17:24.779: E/WindowManager(271): at com.android.server.wm.Session.onTransact(Session.java:111)
05-25 23:17:24.779: E/WindowManager(271): at android.os.Binder.execTransact(Binder.java:338)
05-25 23:17:24.779: E/WindowManager(271): at com.android.server.SystemServer.init1(Native Method)
05-25 23:17:24.779: E/WindowManager(271): at com.android.server.SystemServer.main(SystemServer.java:814)
05-25 23:17:24.779: E/WindowManager(271): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 23:17:24.779: E/WindowManager(271): at java.lang.reflect.Method.invoke(Method.java:511)
05-25 23:17:24.779: E/WindowManager(271): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-25 23:17:24.779: E/WindowManager(271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-25 23:17:24.779: E/WindowManager(271): at dalvik.system.NativeStart.main(Native Method)
05-25 23:17:24.969: D/dalvikvm(355): GC_CONCURRENT freed 542K, 40% free 7362K/12231K, paused 2ms+2ms
05-25 23:17:25.079: E/AppWidgetHost(471): could not find cached view
05-25 23:17:25.079: E/AppWidgetHost(471): java.lang.Exception
05-25 23:17:25.079: E/AppWidgetHost(471): at com.sonyericsson.util.LogUtil.reportError(LogUtil.java:54)
05-25 23:17:25.079: E/AppWidgetHost(471): at com.sonyericsson.home.widget.WidgetManager.getWidgetView(WidgetManager.java:135)
05-25 23:17:25.079: E/AppWidgetHost(471): at com.sonyericsson.home.layer.desktop.DesktopController$19.run(DesktopController.java:2593)
05-25 23:17:25.079: E/AppWidgetHost(471): at com.sonyericsson.util.DeferredHandler$Impl.handleMessage(DeferredHandler.java:62)
05-25 23:17:25.079: E/AppWidgetHost(471): at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 23:17:25.079: E/AppWidgetHost(471): at android.os.Looper.loop(Looper.java:137)
05-25 23:17:25.079: E/AppWidgetHost(471): at android.app.ActivityThread.main(ActivityThread.java:4441)
05-25 23:17:25.079: E/AppWidgetHost(471): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 23:17:25.079: E/AppWidgetHost(471): at java.lang.reflect.Method.invoke(Method.java:511)
05-25 23:17:25.079: E/AppWidgetHost(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-25 23:17:25.079: E/AppWidgetHost(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-25 23:17:25.079: E/AppWidgetHost(471): at dalvik.system.NativeStart.main(Native Method)
05-25 23:17:25.099: D/dalvikvm(471): GC_CONCURRENT freed 1923K, 41% free 8961K/15047K, paused 2ms+6ms
05-25 23:17:25.159: E/AppWidgetHost(471): could not find cached view
05-25 23:17:25.159: E/AppWidgetHost(471): java.lang.Exception
05-25 23:17:25.159: E/AppWidgetHost(471): at com.sonyericsson.util.LogUtil.reportError(LogUtil.java:54)
05-25 23:17:25.159: E/AppWidgetHost(471): at com.sonyericsson.home.widget.WidgetManager.getWidgetView(WidgetManager.java:135)
05-25 23:17:25.159: E/AppWidgetHost(471): at com.sonyericsson.home.layer.desktop.DesktopController$19.run(DesktopController.java:2593)
05-25 23:17:25.159: E/AppWidgetHost(471): at com.sonyericsson.util.DeferredHandler$Impl.handleMessage(DeferredHandler.java:62)
05-25 23:17:25.159: E/AppWidgetHost(471): at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 23:17:25.159: E/AppWidgetHost(471): at android.os.Looper.loop(Looper.java:137)
05-25 23:17:25.159: E/AppWidgetHost(471): at android.app.ActivityThread.main(ActivityThread.java:4441)
05-25 23:17:25.159: E/AppWidgetHost(471): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 23:17:25.159: E/AppWidgetHost(471): at java.lang.reflect.Method.invoke(Method.java:511)
05-25 23:17:25.159: E/AppWidgetHost(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-25 23:17:25.159: E/AppWidgetHost(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-25 23:17:25.159: E/AppWidgetHost(471): at dalvik.system.NativeStart.main(Native Method)
4

0 回答 0