Reputation: 5
I want a welcome screen to appear and then after a delay of few seconds start a new activity. Ex. I have mainactivity.java and second activity.java. main activity displays a welcome message and second activity does work. I am using intent to start second activity from main. But the main does not start instead directly second is loaded. Help!!!
Upvotes: 0
Views: 3150
Reputation: 6522
Are you talking about a splash screen? Try this tutorial, it should get you exactly what you want.
Upvotes: 0
Reputation: 2824
use handler to do that for example
private Handler handler;
private Runnable delayRunnable;
handler = new Handler();
delayRunnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Add your intent here for Second Activity
Intent i = new Intent(getApplicationContext(), secondactivity.class);
startActivity(i);
}
};
handler.postDelayed(delayRunnable, 3000);
Upvotes: 1
Reputation: 4799
Try:
private Handler handler = new Handler();
handler.postAtTime(splashTimeTask, SystemClock.uptimeMillis() + 500);
private Runnable splashTimeTask = new Runnable() {
public void run() {
}
};
Upvotes: 0