Reputation: 371
I have an app that is working fine when the dev option Don't keep activities is ON.
When is OFF though,
every time the app goes to background and resumes, the onCreate function is called again. In there I am re-creating the last app state.
Now the problem is that a simple animation that happens on user action, doesn't start and the animation handlers never called.
It seems like the animation is ignored. And this only happens when the activity is killed and created again.
And the weirdest part is that I have 4 animations, 2 for one imageview (opening, closing) and 2 for another imageview (opening, closing).
And this happens onmly on the opening animations.
Could you help me out?
the animation xmls (for one of the opening/closing anims)
redShow animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="0.1"
android:toAlpha="1.0"
android:duration="800"
/>
<scale android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="800">
</scale>
</set>
redHide animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="300"
/>
<scale android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="300">
</scale>
</set>
the code (at onCreate) where I am initialising stuff
red = (ImageView) findViewById(R.id.red);
redHide = AnimationUtils.loadAnimation(this, R.anim.red_hide);
redHide.setFillAfter(true);
redHide.setAnimationListener(this);
redShow = AnimationUtils.loadAnimation(this, R.anim.red_show);
redShow.setFillAfter(true);
redShow.setAnimationListener(this);
the handlers and the methods I am callling
private void showRed() {
red.startAnimation(redShow); //this is the one that is not happening
}
private void hideRed() {
red.startAnimation(redHide);
}
@Override
public void onAnimationEnd(Animation a) {
}
@Override
public void onAnimationRepeat(Animation a) {
}
@Override
public void onAnimationStart(Animation a) {
}
G
Upvotes: 1
Views: 1189
Reputation: 1809
Things you could try are:
Just some ideas..
A blinking red warning lamp went off when you wrote that you are recreating the last app state since the code you are showing to us looks just fine.
Upvotes: 4