Implemented activity to activity shared element transition. It works fine but receiving crashes on very few devices that are running >=LOLLIPOP.
Report:
Fatal Exception: java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:1550)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.ActivityManagerProxy.isTopOfTask(ActivityManagerNative.java:4654)
at android.app.Activity.isTopOfTask(Activity.java:5557)
at android.app.Activity.startActivityForResult(Activity.java:3903)
at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:65)
at android.app.Activity.startActivity(Activity.java:4146)
at com.mypackage.Activity1.method1(Activity1.java:414).
tried this:
Intent intent = new Intent(Activity1.this, Activity2.class);
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(Activity1.this,
logoImageView,
ViewCompat.getTransitionName(logoImageView));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
startActivity(intent, options.toBundle());
} else {
startActivity(intent);
}
overridePendingTransition(R.anim.stay, R.anim.stay);
then this from this sof IllegalArgumentException in ActivityManagerProxy:
Intent intent = new Intent(Activity1.this, Activity2.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(Activity1.this,
logoImageView,
getString(R.string.splashLogoSharedTransition));
startActivity(intent, options.toBundle());
} else {
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(SplashActivity.this,
logoImageView,
getString(R.string.splashLogoSharedTransition));
ActivityCompat.startActivity(SplashActivity.this, intent, options.toBundle());
}
overridePendingTransition(R.anim.stay, R.anim.stay);
Crash happens with the both the codes at:
startActivity(intent, options.toBundle());
Ever faced ? Any hints ?
It seems like you are using
Window.FEATURE_CONTENT_TRANSITIONS
. But Instead, you should be usingWindow.FEATURE_ACTIVITY_TRANSITIONS
.In your
styles-v21.xml
, add:From the Docs :
Window.FEATURE_CONTENT_TRANSITIONS
:Window.FEATURE_ACTIVITY_TRANSITIONS
:See this post for more info.
According to this post you shouldn't use ActivityOptionsCompat above API 21: https://stackoverflow.com/a/42455484/1067763
I don't use it, but I still have this crash:
Crashes after startActivityForResult in API 27
I think it's still using the wrong version somehow.
Still, knowing this you might be able to solve your issue.