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

  • SEARCH
  • Home
  • 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 8438259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:39:44+00:00 2026-06-10T07:39:44+00:00

I am making a simple Android program that runs mnemonics or math exercises for

  • 0

I am making a simple Android program that runs mnemonics or math exercises for training purposes.
I have a “new exercise” button that changes question and answer. I want to implement a “text to speech” mode, where the software reads the question and the answer. After they are spoken, it should calculate a new question and start again.

I am using OnUtteranceCompleted to determine if the speech has ended. My problem is that I can’t access my “new exercise” button from the callback.

I am using this:

private TextToSpeech.OnUtteranceCompletedListener onUtteranceCompleted = new TextToSpeech.OnUtteranceCompletedListener()
{
        @Override
        public void onUtteranceCompleted(String utteranceId)
        {
                if(0 == utteranceId.compareToIgnoreCase(END_OF_SPEECH))
                {
                        Log.i("TTS","Completed");
                        if (TTSMode == TTS_MODE_ON) {
                            //Start new
                             Log.i("TTS","TTS mode is on: start new exercize");
                            NewExercize();
                             btnNewEx.performClick();

                        }
                }

        }
};

I got the following error:
$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

I am able to generate the new question/answer, but I can’t use the button to change the fields with the new question or answer, wich are used by the TTS engine.

Any ideas?

  • 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-10T07:39:46+00:00Added an answer on June 10, 2026 at 7:39 am

    You need to use runOnUiThread:

    context.runOnUiThread( new Runnable() {
        public void run() {
            btnNewEx.performClick();
        }
    });
    

    (you can omit “context.” if “this” is an Activity or Service subclass)

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

Sidebar

Related Questions

I am new to android developement. I am making a simple expense management program
I am also new to Java and Android Development, been making a simple game
Good afternoon. I have been making a small openGL based app for android that
I'm making a simple Android game written in Java. I have my activity... public
I am new to android development, making a simple game and using onKeyDown(.....) function
Im just making a simple app that will vibrate when the button is clicked,
Hi I want to try making a simple application for android phones for which
I'm making a simple drawing app on Android. I'm using the FingerPaint.java provided with
in making a simple cgi server for a course. To do that in some
I'm making a simple URL request with code like this: URL url = new

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.