Display initial Launch Screen(Activity) in Android

Most of Android Apps display Launch Screen, when Application is being launched, for few Seconds.
To cause delay Thread.sleep() is used with 5000 milliseconds, in below code.
Below is an example of the same.

import android.app.Activity;
import android.os.Bundle;

public class LoginPage extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_page);
}
}

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;

import java.util.Timer;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

public class MyActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.launch_activity);
Thread timer= new Thread()
{
public void run()
{
try
{
sleep(5000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
finally
{
try {
Intent i = new Intent(getBaseContext(), NewActivity.class);
startActivity(i);
finish();
}catch(Exception e){
e.printStackTrace();
}
}
}
};
timer.start();
}
}

You may also like to read:

Leave a Reply