Skip to content

Instantly share code, notes, and snippets.

@anry200
Created February 27, 2017 11:27
Show Gist options
  • Save anry200/f0e82f0a9ef079a853d411e8bf9e8fa9 to your computer and use it in GitHub Desktop.
Save anry200/f0e82f0a9ef079a853d411e8bf9e8fa9 to your computer and use it in GitHub Desktop.
Disable animation when starting LoginActivity from another activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
//Disable start animation
overridePendingTransition(0, 0);
getWindow().setWindowAnimations(0);
super.onCreate();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (!userManager.isLoggedIn()) {
startLoginActivityAndFinishCurrent()
}
super.onCreate();
}
private startLoginActivityAndFinishCurrent() {
Intent intent = new Intent();
intent.setClass(this, LoginFormActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
//disable "finish" animation, should be called after startActivity
overridePendingTransition(0, 0);
finish();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment