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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:14:00+00:00 2026-06-06T01:14:00+00:00

Hello I would like to display an other splashscreen after the default one, if

  • 0

Hello I would like to display an other splashscreen after the default one, if the App starts for the first time(right after installation e.g.)

So I wrote this. But the new Activity does not start it stays at the Splash screen. Can somebody say whats wrong with it?

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.TextView;

    public class splash extends Activity {
         private Thread splashTread;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);

            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
            if(!prefs.getBoolean("firstTime", false)) {
                // run your one time code
                 Intent i = new Intent(splash.this, main.class);

                         startActivity(i);
                SharedPreferences.Editor editor = prefs.edit();
                editor.putBoolean("firstTime", true);
                editor.commit();


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

                                 //wait 2 sec
                                 wait(2000);
                         }

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



                         //start a new activity
                         Intent i = new Intent();
                         i.setClass(splash.this, main.class);
                                 startActivity(i);

                         stop();
                     }
                 }
             };

             splashTread.start();

        }

    }
    }

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-06-06T01:14:01+00:00Added an answer on June 6, 2026 at 1:14 am

    From what I’ve seen, your code runs the same Activity (main) regardless of whether the launch is the first time or not. I’m assuming your purpose is to immediately launch the alternate splash screen if it’s the first launch, otherwise to proceed to the main Activity after 2 seconds. Also, I would recommend using a Handler rather than a Thread, since you’re only making use of it once, and on a delay. Try this:

        public class splash extends Activity
    {
        private Handler handler = new Handler()
        {
            public void handleMessage(Message msg)
            {
                Intent i = new Intent(splash.this, main.class);
                splash.this.startActivity(i);
                                     this.finish()
            }
        };
    
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
    
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
            if(!prefs.getBoolean("first_time", false))
            {
                SharedPreferences.Editor editor = prefs.edit();
                editor.putBoolean("first_time", true);
                editor.commit();
                Intent i = new Intent(splash.this, otherSplash.class);
                this.startActivity(i);
                                     this.finish();
            }
            else
            {
                this.setContentView(R.layout.splash);
                handler.sendEmptyMessageDelayed(0, 2000);
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello In my android application on click of image i would like to display
hello i would like to know if there is any dll or global hook
Hello I would like to use preg_match in PHP to parse the Desired text
Hello I would like to use the sass module in a play application. We
Hello I would like to know if my script is good; I want to
Hello I have a datatable that I would like to filter with a single
Hello! I would like to extract all citations from a text. Additionally, the name
Hello I have 2 lists that contains the same objects. I would like to
I have a file template.txt which contains the following: Hello ${something} I would like
I would like clearly display some text coded in html, at the moment I

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.