Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8298765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:54:09+00:00 2026-06-08T15:54:09+00:00

I am working on text to voice app. I have given an input string

  • 0

I am working on text to voice app. I have given an input string and make conversion by means of button. when i clicked the button the app get closed unexpectedly. app is going fine when input is hard coded.

EditText text;
String[] texts ;
TextToSpeech tts;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    texts = new String[3];
    text = (EditText)findViewById(R.id.ttexttovoice);
    //Editable debug = text.getText();
    texts[0] = text.getText().toString();
    Button b = (Button)findViewById(R.id.btexttovoice);
    b.setOnClickListener(this);
    tts = new TextToSpeech(textvoice.this,new TextToSpeech.OnInitListener(){

        @Override
        public void onInit(int status) {
            // TODO Auto-generated method stub
            if(status!= TextToSpeech.ERROR)
            {
                tts.setLanguage(Locale.US);

            }
            }
    });

}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    if(tts!= null)
    {
        tts.stop();
        tts.shutdown();
    }
    super.onPause();
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Random r = new Random();
    String rn = texts[r.nextInt(3)];
    tts.speak(rn, TextToSpeech.QUEUE_FLUSH, null);
}

}
Here is the logcat:

07-29 07:18:52.635: ERROR/AndroidRuntime(246): Uncaught handler: thread main exiting due to uncaught exception
07-29 07:18:52.665: ERROR/AndroidRuntime(246): java.lang.NullPointerException: println needs a message
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.util.Log.println(Native Method)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.util.Log.i(Log.java:136)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.speech.tts.TextToSpeech.speak(TextToSpeech.java:673)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at org.textvoice.textvoice.onClick(textvoice.java:64)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.View.performClick(View.java:2364)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.View.onTouchEvent(View.java:4179)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.widget.TextView.onTouchEvent(TextView.java:6541)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.View.dispatchTouchEvent(View.java:3709)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.os.Looper.loop(Looper.java:123)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at android.app.ActivityThread.main(ActivityThread.java:4363)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at java.lang.reflect.Method.invokeNative(Native Method)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at java.lang.reflect.Method.invoke(Method.java:521)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-29 07:18:52.665: ERROR/AndroidRuntime(246):     at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:54:12+00:00Added an answer on June 8, 2026 at 3:54 pm

    I think texts[r.nextInt(3)] is null.pls guaranty texts[0]~text[2] have values strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app uses text-to-speech after a voice recognition command. I had it working earlier
This is driving me nuts. I have a working text based application. It has
I have a longer text saved in a String. I would like to print
Have an app written that automatically reads out received text messages when they arrive.
I'm working on a Text Addition feature for my App. This text is going
I am working with text which is, unfortunately, given in ALL CAPS. The default
I'm working with text files. Actually one file, where I have to copy information
I am working on a project where I have to record a voice covert
I'm currently working on a Android+AppEngine project using voice as my main input method.
I'm working on a text game engine, and have run into a snag while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.