[英]Why can't I use Intent.FLAG_ACTIVITY_NEW_TASK in PendingIntent
[英]Why can't I disable the animation for changing activities when using FLAG_ACTIVITY_REORDER_TO_FRONT?
在我的游戏中,当用户决定将屏幕从消息屏幕切换到个人资料屏幕时,我想确保用户可以切换屏幕并能够保持之前的活动。
所以我有这段代码:
Intent intent = new Intent(this, Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivityIfNeeded(intent, 0);
overridePendingTransition(0, 0);
它有效,除了它只在第一次从屏幕切换时禁用动画,之后它不起作用。 它播放动画,我不想要那个。
我该如何解决?
您可以按照@DKV 的建议禁用动画。
而不是这个
Intent intent = new Intent(this, Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivityIfNeeded(intent, 0);
overridePendingTransition(0, 0); // remove this line
尝试使用这个
Intent intent = new Intent(this, Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityIfNeeded(intent, 0);
注意
添加标志
不是
设置标志
我按照这个答案使它起作用。
创建一个没有指定动画的样式: <item name="android:windowAnimationStyle">@null</item>
然后将其用作清单中该活动的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.