Set animation listener to Activity animations

Viewed 29494

I am using overridePendingTransition method to perform custom Activity animations.

I would like to know when the animation ends ( a callback/listener ).

Is there any direct way of achieving this, if not please suggest me some work around.

4 Answers

@Hambug solution is nice. But there is problem. onEnterAnimationComplete will work on Lollipop and above API (21).

@Override
public void onEnterAnimationComplete() {
    super.onEnterAnimationComplete();
    //write code here.
 }

whatever code you write in above method, won't execute on prelolipop devices. So you should put a version check and write it according to you need e.g. in onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
        //write code here.
    }
Related