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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:34:11+00:00 2026-05-31T18:34:11+00:00

Ok, so i created a very simple splash screen using this tutorial: http://p-xr.com/android-tutorial-how-to-make-a-basic-splash-screen/ The

  • 0

Ok, so i created a very simple splash screen using this tutorial:

http://p-xr.com/android-tutorial-how-to-make-a-basic-splash-screen/

The problem is that if the user hits the home button or the back button to exit the app during the splash screens duration then the app will re-open to the second screen after the splash screen would have been done if the user did no exit.

My code is pretty much that of the tutorial. any help?

Thanks

  • 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-05-31T18:34:13+00:00Added an answer on May 31, 2026 at 6:34 pm

    I have modified the code to make use of the lifecycle methods better. enjoyed changing it. 🙂

       public class SplashScreen extends Activity {
    
            protected int _splashTime = 5000; 
    
            private Thread splashTread;
    
            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.splash);
    
    
                final SplashScreen sPlashScreen = this; 
    
                // thread for displaying the SplashScreen
                splashTread = new Thread() {
                    @Override
                    public void run() {
                        try {                   
                            synchronized(this){
                                wait(_splashTime);
                            }
    
                        } catch(InterruptedException e) {} 
                        finally {
    
                            if(!isFinishing()) // This pretty useful boolean val tells if 
     //user has pressed the back button. very useful.
                            {Intent i = new Intent(SplashScreen.this, Main.class);
    
                            startActivity(i);
                             finish();
                             }
    
    
                            stop();
                        }
                    }
                };
    
                splashTread.start();
            }
            @Override
            public boolean onTouchEvent(MotionEvent event) {
    
    
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    Toast.makeText(this,"exec---",Toast.LENGTH_LONG).show();
                    synchronized(splashTread){
                        splashTread.notifyAll();
                    }
                }
                return true;
            }
            @Override
            protected void onPause() {
    
                super.onPause();
    
                if(splashTread.getState()==Thread.State.TIMED_WAITING){
                    //Thread is still waiting and Activity is paused. Means user has pressed Home. Bail out
                    finish();
                }
    
            }
        }
    

    My point of view is that the use of Splash Screen is not frequent but maybe needed. If you are doing heavy work behind the screen( such as games).

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

Sidebar

Related Questions

I have created a very simple program that uses recursion. I'm using the g++
I've created a very simple Windows Service projects with this tutorial . I've build
I've created a very simple prototype application in Visual Basic 2010 Express. The problem
I am using SQL Server 2008 Enterprise. I have created a very simple test
I created a very simple test control that has a Rectangle on a canvas
I created a very simple progam whith a menu, that take a value, then
I have created a very simple Entity Framework 4.0 model using VS2010 Professional. Ignore
i've created a very simple mysql class in c+, but when happen that mysql
I installed VS10 side-by-side with VS9 and created a very simple application using it:
I created a very simple WCF class library and added this project to the

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.