Friday, 1 August 2014

Splashscreen using Thread


      
        /****** Create Thread that will sleep for 5 seconds *************/      
       Thread background = new Thread() {
           public void run() {
              
               try {
                   // Thread will sleep for 5 seconds
                   sleep(5*1000);
                  
                   // After 5 seconds redirect to another intent
                   Intent i=new Intent(getBaseContext(),Splahnextactivity.class);
                   startActivity(i);
                  
                   //Remove activity
                   finish();
                  
               } catch (Exception e) {
              
               }
           }
       };
      
       // start thread
       background.start();


method2:

new Handler().postDelayed(new Runnable() {
          
            @Override
            public void run() {
                startActivity(new Intent(getApplicationContext(),Splahnextactivity.class));
                finish();
              
            }
        }, 2*1000);




No comments:

Post a Comment