I have a splash screen and use a timer thread to display it for 2.5 seconds, that works fine but I get a blank page. If I remove the timer thread, my page displays perfectly.
Thread splashTimer = new Thread(){
public void run(){
try{
int splashTimer = 0;
while (splashTimer < 2500){
sleep(200);
splashTimer = splashTimer + 200;
Intent navMainPage = new Intent("com.extempor.cheetah.CLEARSCREEN");
startActivity(navMainPage);
}
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
finish();
}
}
};
splashTimer.run();
The page when it displays correctly shows a png image. I tried just a textview but nothing works while I have the timer thread. I’m using 2.3.3 and Eclipse 3.7
It seems that the timer thread is the standard way to show a splash screen, but why is no content displayed when I use it?
First and foremost you should absolutely not make your users wait for any amount of time that is not absolutely necessary. If you need to do some kind of time consuming work at start up then show a splash screen during that and use a handler callback to hide it when the work is complete. Making your users wait for 2 or 3 seconds for no reason just so you can show them a pretty picture is silly and will turn people off from using your application IMO.
I achieved this effect using a fadeOut animation.
see this question for example animation code. If you use the code from that example you can use something like this to delay it for 2 seconds
Again please really consider using a splash only if you have some real work to do, don’t force your users to wait for 2 seconds with no good reason.