Adrail
Adrail

Reputation: 1

The Main Activity not showing after the Animated Splash Screen

I tried to do an Animated Splash Screen, and the problem is that the MainActivity is not shown after the Splash Screen. I add some code, but it makes it crash. Can You help me please. Below the code for Splash Screen Activity

   public class SplashScreenActivity extends Activity {
 public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Window window = getWindow();
        window.setFormat(PixelFormat.RGBA_8888);
    }
  /** Called when the activity is first created. */
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       CountDown _tik;
       _tik=new CountDown(3000,3000,this,MainActivity.class);// It delay th
  screen for 3 second and after that switch to my MainActivity
       _tik.start();
       StartAnimations();
       }


   private void StartAnimations() {
   Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
   anim.reset();
   LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
   l.clearAnimation();
   l.startAnimation(anim);

   anim = AnimationUtils.loadAnimation(this, R.anim.translate);
   anim.reset();
   ImageView iv = (ImageView) findViewById(R.id.logo);
   iv.clearAnimation();
   iv.startAnimation(anim);



   }

Below the CountDown code

public class CountDown extends CountDownTimer{
private Activity _act;
private Class _cls;
public CountDown(long millisInFuture, long countDownInterval,Activity act,Class cls) {
super(millisInFuture, countDownInterval);
_act=act;
_cls=cls;
}
@Override
public void onFinish() {
_act.startActivity(new Intent(_act,_cls));
_act.finish();
}
@Override
public void onTick(long millisUntilFinished) {

}

And the last one is the activity that I want to make shown after the splash screen

    public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

Please Note. The Animation IS working GOOD. Only the problem is when I'm tring to get MainActivity After Splash Screen.

Upvotes: 0

Views: 308

Answers (1)

Jashan PJ
Jashan PJ

Reputation: 4408

Did you miss to set an animation listener? i think you must call your main activity from onAnimationEnd method of animation Listener. May be this will help you Question will help you.

Upvotes: 2

Related Questions