Skip to content

Instantly share code, notes, and snippets.

@chrislacy
Created July 24, 2013 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislacy/6068493 to your computer and use it in GitHub Desktop.
Save chrislacy/6068493 to your computer and use it in GitHub Desktop.
So long as you pass in a valid View, and are using Jelly Bean or later, the animation should automatically apply.
@SuppressLint("NewApi")
public boolean startActivity(View v, Intent intent, Object tag) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Only launch using the new animation if the shortcut has not opted out (this is a
// private contract between launcher and may be ignored in the future).
boolean useLaunchAnimation = (v != null) &&
!intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
if (useLaunchAnimation) {
ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0,
v.getMeasuredWidth(), v.getMeasuredHeight());
startActivity(intent, opts.toBundle());
} else {
startActivity(intent);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment