My question is suppose i have to views(Screen). when i open my application from the emulator first screen should stay for just 5 secs and automatically new screen should appear(2nd). i Know i can do this through timer concept but dnt know hwto do that in android? So pls help me in this problem.
-
1you looking to make a splash screen?wheaties– wheaties2010年09月28日 14:10:58 +00:00Commented Sep 28, 2010 at 14:10
-
2May I suggest against implementing a splash screen? I really don't want to wait 5 seconds when I start an app on a phone. This is not a desktop application.EboMike– EboMike2010年09月28日 14:14:06 +00:00Commented Sep 28, 2010 at 14:14
1 Answer 1
I completely agree with EboMike about not showing a splash screen. It's a bad practice with any app (desktop or android) and often just covers up sloppy programming. Get the user to do useful work as soon as possible and do any other startup work asynchronously.
However, sometimes lawyers are in charge of software, sometimes it's a marketing person, and sometime you just can't defer long startup code. In this case, you need an answer. The simplest is to have your main activity be your splash scree. In the splash screen activity, create a handler to start your real main activity doing something like this:
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
startActivity(...);
finish();
}
};
handler.sendEmptyMessageDelayed(0, 5000);