I have a splash screen that i want to run before my main app screen. However, when the timer ends, the applicaiton crashes. Any ideas on why this happens? Thanks in advance.
Below is the referenced code
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread timer = new Thread() {
// Whatever is enclosed in the {} of method run(), runs when we
// start the application
public void run() {
try {
sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent openMainScreen = new Intent("com.package.Main_Screen");
startActivity(openMainScreen);
}
}
};
timer.start();
}
}
Why don’t you simply use this kind of Intent,
And also make sure you you have added the Activity in your manifest like this,