What's best practice for structuring an activity, which should begin by displaying an animated image, and then move to another "activity" by intent when the animation is complete? I understand some of the basic principles, but I am getting lost on structuring the flow here.
public class Scanimation extends Activity {
//create name of animation
Animation myFadeInAnimation;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scanning_view);
//grab the imageview from the layout, and then load the animation listener
ImageView myImageView = (ImageView) findViewById(R.id.blinkingView01);
AnimationListener al= new AnimationListener() {
public void onAnimationStart(Animation animation) {
// do nothing
}
public void onAnimationRepeat(Animation animation) {
// do nothing
}
// at the end of the animation, start new activity
public void onAnimationEnd(Animation animation) {
Intent myIntent = new Intent (view.getContext(), LastActivity.class);
startActivity(myIntent);
}
// get the animation effects which are in the XML file and defines how to animate it Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
};
//okay now start the animation on screen
myImageView.startAnimation(myFadeInAnimation);
// go get the vibration service and vibrate quickly while screen is animated
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
long milliseconds = 2000;
v.vibrate(milliseconds);
long[] pattern = { 500, 300 };
v.vibrate(pattern, -1);
}
}
Most of the tutorials I've read appear to use this type of flow. I'm pulling in my main layout and view, then animating the specific view as well as vibrating the device for a quick second. At the end of the animation, the intent to start my next or last activity does not fire.
What am I missing here?