This code is working as expected on all devices except Sony devices with activated STAMINA mode:
int backStackCount = getSupportFragmentManager().getBackStackEntryCount();
getFragmentManager()
.beginTransaction()
.setCustomAnimations(backStackCount == 0? R.animator.noanim : R.animator.slide_in,
R.animator.zoom_out, R.animator.zoom_in, backStackCount == 0? R.animator.noanim : R.animator.slide_out)
.replace(R.id.container, fragment, String.valueOf(backStackCount))
.addToBackStack(fragment.getClass().toString())
.commit();
With STAMINA mode the first Fragment is loaded normally, but the next one does not show up at all (the screen remains black). If I comment out the setCustomAnimations
method, the transaction works as expected. What is going on here, how to get the transaction working with activated STAMINA mode?
R.animator.slide_in:
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:valueFrom="1.0"
android:valueTo="0"
android:propertyName="xFraction"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
EDIT: solved by myself, see below