错误日志如下
java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:1624)
at android.os.Parcel.readException(Parcel.java:1573)
at android.app.ActivityManagerProxy.isTopOfTask(ActivityManagerNative.java:4907)
at android.app.Activity.isTopOfTask(Activity.java:5691)
at android.app.Activity.cancelInputsAndStartExitTransition(Activity.java:4029)
at android.app.Activity.startActivityForResult(Activity.java:4006)
at android.support.v4.app.j.startActivityForResult(SourceFile:54)
at android.support.v4.app.n.startActivityForResult(SourceFile:65)
at android.app.Activity.startActivity(Activity.java:4266)
执行动画时,看起来有些不对劲,但我不知道如何解决这个问题。顺便说一句,我用它来开始活动
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, sharedElements);
ActivityCompat.startActivity(context, intent, optionsCompat.toBundle());
需要 帮助
答案 0 :(得分:0)
不要从活动中投射上下文:
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(context, sharedElements);
ActivityCompat.startActivity(context, intent, optionsCompat.toBundle());
答案 1 :(得分:0)
像这样使用:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat optionsCompat =
ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, sharedElements);
ActivityCompat.startActivity(context, intent, optionsCompat.toBundle());
} else {
startActivity(context, intent);
}