I want to make an application that shows a frame by frame animation when starting up. After the animation finishes, I want to send an intent to the main class (ReminderListActivity). However I can’t seem to find how I define when the animation finishes.
Here’s the relevant code:
The Animation class;
public class LoadActivity extends Activity {
AnimationDrawable animation;
long endTimeMillis;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.load_animation);
startAnimation();
}
class Starter implements Runnable {
public void run() {
animation.start();
}
}
private void startAnimation(){
animation = new AnimationDrawable();
animation.addFrame(getResources().getDrawable(R.drawable.dude1), 75);
//....
animation.addFrame(getResources().getDrawable(R.drawable.dude10), 75);
animation.setOneShot(true);
ImageView imageView = (ImageView) findViewById(R.id.img);
imageView.setImageDrawable(animation);
imageView.post(new Starter());
Intent i = new Intent(LoadActivity.this, ReminderListActivity.class);
startActivity(i);
}
}
There is no way to register a listener to be called when the one-shot animation ends. As a work-around as you already know the duration of the animation, you may start the activity after the known delay: