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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:33:07+00:00 2026-06-07T00:33:07+00:00

public class tryAnimActivity extends Activity { /** * The thread to process splash screen

  • 0
public class tryAnimActivity extends Activity 
{

  /**
   * The thread to process splash screen events
   */
  private Thread mSplashThread;    

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Splash screen view
    setContentView(R.layout.janman);

    final tryAnimActivity sPlashScreen = this;   

    // The thread to wait for splash screen events
    mSplashThread =  new Thread(){
        @Override
        public void run(){
            try {
                synchronized(this){
                    // Wait given period of time or exit on touch
                    wait(5000);
                }
            }
            catch(InterruptedException ex){                    
            }

            finish();

            // Run next activity
            Intent intent = new Intent();
            intent.setClass(sPlashScreen, TabsActivity.class);
            startActivity(intent);
            stop();                    
        }
    };

    mSplashThread.start();        
  }

  /**
   * Processes splash screen touch events
   */
  @Override
  public boolean onTouchEvent(MotionEvent evt)
  {
    if(evt.getAction() == MotionEvent.ACTION_DOWN)
    {
        synchronized(mSplashThread){
            mSplashThread.notifyAll();
        }
    }
    return true;
  }    
} 

whats the problem with this code? On clicking, it crashes down. Also, the next activity does not start after the end of this activity. This is the activity used for displaying splashscreen.

  • 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-07T00:33:09+00:00Added an answer on June 7, 2026 at 12:33 am

    I prefer to use Runnable element instead of Thread. My splash code for the activity below works well. I hope it helps you:

    public class SplashScreenActivity extends Activity implements OnTouchListener {
    
        private int SPLASH_DISPLAY_LENGTH = 3000;
    
        private Handler splashHandler;
        private Runnable splashRunnable;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
    
            findViewById(R.id.splash_img).setOnTouchListener(this);
    
            splashHandler = new Handler();
            splashRunnable = new Runnable()
            {
                @Override
                public void run()
                {
                    SplashScreenActivity.this.finish();
                    Intent mainIntent = new Intent(SplashScreenActivity.this, HomeActivity.class);
                    startActivity(mainIntent);
                }
            };
    
            splashHandler.postDelayed(splashRunnable, SPLASH_DISPLAY_LENGTH);
    
        }
    
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN){
                splashHandler.removeCallbacks(splashRunnable);
                SplashScreenActivity.this.finish();
                Intent mainIntent = new Intent(SplashScreenActivity.this, HomeActivity.class);
                startActivity(mainIntent);
            }
            return true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class upload extends Activity { private static final int CAMERA_REQUEST = 1888; private
public class SaveData extends Activity implements OnClickListener { private DataManipulator dh; static final int
public class Test extends Thread{ public void hello(String s){ System.out.println(s); } public void run(){
public class BobDatabase extends SQLiteOpenHelper{ private static final String DATABASE_NAME = bob.db; private static
public class Browser1Activity extends Activity { TextView url; WebView ourBrow; @Override protected void onCreate(Bundle
public class HomeActivity extends Activity{ // public ArrayList<User> users1 = new ArrayList<User>(); @Override public
public class GenericDao <T, PK extends Serializable> { private final Class<T> type; @Resource(name =
public class master extends Activity { ProgressDialog progressDialog; EditText tahmini_kelime; EditText girilen_sayi ; EditText
public class MCQSample extends Activity implements OnClickListener{ TextView title; String gotBread; RadioGroup AnswerRG; int
public class PackageTabActivity extends ListActivity{ HashMap<String,Object> hm ; ArrayList<HashMap<String,Object>> applistwithicon ; private static final

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.