I am trying to implement a quick SplashActivity that slides in from the right to the left, then slides out to the left as the MainActivity slides in to the right. Currently, the animation XMLs are in place but it isn't working, the splash screen just appears, then the transition to the main activiity doesn't work either. Here is the SplashActivity that is the beginning activity of the app.
public class SplashActivity extends Activity{
private int SPLASH_MILLISECONDS = 1000;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
setContentView(R.layout.activity_splash);
runTimer();
}
private void runTimer() {
Timer timeout = new Timer();
timeout.schedule(new TimerTask()
{
@Override
public void run()
{
runOnUiThread(new Runnable(){
@Override
public void run() {
goToMainActivity();
}
});
}
}, SPLASH_MILLISECONDS);
}
private void goToMainActivity(){
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION );
startActivity(intent);
finish();
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
}
This for some reason does not work, what is it I am doing wrong?
EDIT: This is my new goToMainActivity() method, yet still neither of the 2 animations are working. At this point I don't care much about the first animation working, I just want the second one working.
private void goToMainActivity(){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
finish();
}