Reputation: 13
I currently have an app which loads a screen, OpenActivity, which, has a button saying 'start' which when pressed takes you to MenuActivity.class, actually, the button itself is just a view, and anywhere on the screen can be pressed, you will still go to the MenuActivity.
What I would like to do, is change it so, that the OpenActivity class appears as normal, however, dismisses by itself, after say, 3 seconds, to then show MenuActivity. Although if possible, to be able to control the dismiss action, for example;
Start the App 'OpenActiviy' screen shows for 3 seconds, then dismisses to show MenuActivity, with a callback so I can do something on dismiss OpenActivity BEFORE the MenuActivity shows, I hope this makes sense!
OnCreate for OpenActivity;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.open_app);
Animation a = AnimationUtils.loadAnimation(this, R.anim.disk);
findViewById(R.id.viewOpenApp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(OpenActivity.this, MenuActivity.class));
finish();
}
});
}
Upvotes: 1
Views: 327
Reputation: 7674
Use Handler:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//dismiss the view, start the activity or anything else you need
}
}, 3000); // time to wait before executing the code inside run() in milliseconds
Upvotes: 1