简体   繁体   English

Android:TextToSpeech 不工作

[英]Android:TextToSpeech Not Working

Hi i create one application which is depend on TextToSpeech.您好,我创建了一个依赖于 TextToSpeech 的应用程序。 When i am trying to run my当我试图运行我的
application It show the NullPointerException in Logcat.应用程序它在 Logcat 中显示 NullPointerException。 i search lot but didn't find helpful Answer.Here Check my Code on this link and Here is my logcat.我搜索了很多,但没有找到有用的答案。在这个链接上检查我的代码,这是我的 logcat。

04-10 15:11:37.872: WARN/System.err(2798): java.lang.NullPointerException
04-10 15:11:37.872: WARN/System.err(2798):     at com.example.examguide.ExamAppearingActivity.onCreate(ExamAppearingActivity.java:80)
04-10 15:11:37.872: WARN/System.err(2798):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-10 15:11:37.882: WARN/System.err(2798):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-10 15:11:37.882: WARN/System.err(2798):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-10 15:11:37.882: WARN/System.err(2798):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-10 15:11:37.882: WARN/System.err(2798):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-10 15:11:37.882: WARN/System.err(2798):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 15:11:37.882: WARN/System.err(2798):     at android.os.Looper.loop(Looper.java:123)
04-10 15:11:37.882: WARN/System.err(2798):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-10 15:11:37.882: WARN/System.err(2798):     at java.lang.reflect.Method.invokeNative(Native Method)
04-10 15:11:37.892: WARN/System.err(2798):     at java.lang.reflect.Method.invoke(Method.java:507)
04-10 15:11:37.892: WARN/System.err(2798):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-10 15:11:37.892: WARN/System.err(2798):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-10 15:11:37.892: WARN/System.err(2798):     at dalvik.system.NativeStart.main(Native Method)

Any help is Appreciated...任何帮助表示赞赏...

you have used this code.你已经使用了这个代码。

final List<ObjectiveWiseQuestion> QuestionWiseProfile1= db.getOneQuestion(examId); 

but you have not opened db before.但你之前没有打开过数据库。 So it is getting null. ok write所以它得到 null。好的,写

tts = new TextToSpeech(this, this);

before you use tts object.在你使用 tts object 之前。

The tts object is not initialized. tts object 未初始化。 Hence you get a null pointer exception there.因此,您会在那里得到一个 null 指针异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM