Amirhosein Maleki Amirhosein Maleki - 3 months ago 12
Android Question

How do I make a splash screen end animation and start next activity?

I'm developing a mobile application in Android.
I have an initial animation; after that, control should transfer to the next activity. The transfer doesn't happen.
Where did I go wrong?

public class MainActivity extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);

}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
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);

}



}

Answer
 Intent intent = new Intent();
        intent.setClass(getApplicationContext(), NextActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);

use Intent for your requirement

... slide_out_up.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<translate
    android:duration="400"
    android:fromYDelta="0%"
    android:toYDelta="-100%" />

<alpha
    android:duration="400"
    android:fromAlpha="1"
    android:toAlpha="0" />

 </set>

slide_in_up.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<translate
    android:duration="400"
    android:fromYDelta="100%"
    android:toYDelta="0%" />

<alpha
    android:duration="400"
    android:fromAlpha="0"
    android:toAlpha="1" />

</set>
Comments