Android’s overridePendingTransition and singleInstance

这一生的挚爱 提交于 2019-12-01 03:07:58

问题


I am stuck on an issue with overridePendingTransition not working after changing an activity’s launchMode to ‘singleInstance’. I’d love to hear your inputs on it

I am working on an app to navigate through a deck of cards. To keep things simple, let’s assume the App contains two activities card_deck and card. Tapping anywhere on the card_deck activity opens a card activity. You could then swipe left or right on the card activity to open the next/previous card from the deck. I have a neat enter and exit animation that occurs on swiping through card.

Here is how the android activity stack would look

As you have guessed by now, there are too many activities of type card.

I changed the launchMode of card activity from standard to singleInstace (I had yet another adMob related reason to go the singleInstance route). Now when I call the following code snippet, the animation no longer occurs.

from Card.class

Intent intent = new Intent(activity, Card.class);
activity.startActivity(intent);
activity.overridePendingTransition(enterAnim, exitAnim);

I think the animation is suppressed as there will only be one activity of type card and it's onCreate will not be called (‘cos of making it single instance). I have also tried calling the overridePendingTransition() on onNewIntent()/onResume() but it did not help.

In a nutshell, how could I display enter & exit animation when calling startActivity(activity, A.class) from A.class when ‘A’ has a launchMode of singleTop/singleInstance

来源:https://stackoverflow.com/questions/20895730/android-s-overridependingtransition-and-singleinstance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!