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 8187179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:28:39+00:00 2026-06-07T02:28:39+00:00

So I’ve started to make a simple splash screen (it’s more of an intro

  • 0

So I’ve started to make a simple “splash screen” (it’s more of an intro screen) for a simple android game I’m making for a mobile programming course. I’ve since run into problems. I know I’m supposed to use a thread, but my implementation doesn’t seem to work. You should be able to get a feel for the effect I’m going for.

public class SplashScreen extends Activity {

//how long until we go to the next activity
protected int splashTime = 2000; 
private Thread splashThread;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash_screen);

    final TextView first = (TextView) findViewById(R.id.textView1);
    final TextView second = (TextView) findViewById(R.id.textView2);
    final TextView third = (TextView) findViewById(R.id.textView3);
    final TextView fourth = (TextView) findViewById(R.id.textView4);
    final TextView fifth = (TextView) findViewById(R.id.textView5);
    final TextView sixth = (TextView) findViewById(R.id.textView6);
    final ImageView main_character = (ImageView) findViewById(R.id.imageView1);

    // thread for displaying the SplashScreen
    splashThread = new Thread() {
        @Override
        public void run() {
            try {
                synchronized(this){

                    first.setText("The year is 2048...");

                    wait(splashTime);

                    first.setText("");
                    second.setText("...the Earth's resources have long been depleted");

                    wait(splashTime);

                    second.setText("");
                    third.setText("Attempts have been made to save our home...");

                    wait(splashTime);

                    third.setText("");
                    fourth.setText("...but all has gone awry, trash now rains from the skies");

                    wait(splashTime);

                    fourth.setText("");
                    fifth.setText("Now, only one man can save us, and his name is...");

                    wait(splashTime);

                    fifth.setText("");
                    sixth.setText("The Garbage Man!");
                    main_character.setImageResource(drawable.bobrgb888);

                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            finally {
                finish();

                //start a new activity
                Intent i = new Intent(getApplicationContext(), MainMenu.class);
                startActivity(i);
            }
        }
    };
    splashThread.start();

}

The problem is that the first textview gets called, along with the first wait() call, but then I get a force close.

Here’s my logcat:

07-02 19:35:16.241: W/dalvikvm(709): threadid=9: thread exiting with uncaught exception (group=0x40015560)
07-02 19:35:16.250: E/AndroidRuntime(709): FATAL EXCEPTION: Thread-10
07-02 19:35:16.250: E/AndroidRuntime(709):     android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a    view hierarchy can touch its views.
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.ViewRoot.checkThread(ViewRoot.java:2932)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.ViewRoot.requestLayout(ViewRoot.java:629)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.View.requestLayout(View.java:8267)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.View.requestLayout(View.java:8267)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.View.requestLayout(View.java:8267)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.View.requestLayout(View.java:8267)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:257)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.view.View.requestLayout(View.java:8267)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.widget.TextView.checkForRelayout(TextView.java:5521)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.widget.TextView.setText(TextView.java:2724)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.widget.TextView.setText(TextView.java:2592)
07-02 19:35:16.250: E/AndroidRuntime(709):  at android.widget.TextView.setText(TextView.java:2567)
07-02 19:35:16.250: E/AndroidRuntime(709):  at com.connor.black.SplashScreen$1.run(SplashScreen.java:41)
07-02 19:35:16.420: D/szipinf(709): Initializing inflate state
  • 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-07T02:28:40+00:00Added an answer on June 7, 2026 at 2:28 am

    This is the code I used for my SplashScreen:

    final SplashScreen splash = this;
    
    Thread splashThread = new Thread() {
            @Override
            public void run() {
                go = true;
                while (go) {
                try {
                    int waited = 0;
                    while(_active && (waited < _splashTime)) {
                        sleep(100);
                        if(_active) {
                            waited += 100;
                        }
                    }
                } catch(InterruptedException e) {
                    // do nothing
                } finally {
                    finish();
                    Intent i = new Intent();
                    i.setClass(splash, MyActivity.class);
                    startActivity(i);
                    //stop();
                    go = false;
                }
                }
            }
        };
        splashThread.start();
    

    The problem with your splashscreen is that you’re using wait() incorrectly. What you’re looking for is sleep().

    And to touch the UI thread from a worker thread you need to use runOnUiThread(Runnable action) or a handler.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.