Hello Guys, I want to know how can I open my fragment activity after splash screen activity and in my splash screen I am using animation in my splash screen please help me how can I open it.
Thanks in Advance.
What I have tried:
package com.complainprotectioncell;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class SplashScreen extends AppCompatActivity {
public MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.front_splash_screen);
mp = MediaPlayer.create(this, R.raw.bgr_be_happy);
mp.start();
startAnimation();
}catch(Exception ex)
{
Log.e("Exception" , "Found 1" + ex);
}
}
public void startAnimation()
{
try {
final ImageView imageView = (ImageView) findViewById(R.id.imageView);
final Animation animation_1 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.rotate);
final Animation animation_2 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.antirotate);
final Animation animation_3 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.abc_fade_out);
imageView.startAnimation(animation_2);
animation_2.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
imageView.startAnimation(animation_1);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animation_1.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
try {
startActivity(new Intent(getApplicationContext(), Login.class));
finish();
} catch (Exception ex) {
Log.e("Exception Splash", ex + "");
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}catch(Exception ex)
{
Log.e("Exception" , "Found 2");
}
}
@Override
protected void onStop() {
super.onStop();
try {
if (mp != null && mp.isPlaying()) {
mp.stop();
mp.release();
mp = null;
}
}catch(Exception ex)
{
Log.e("Exception Found", ex + "");
}
}
}