问题
Im trying to change the default animation of activities transitions, and i stuck with a problem.
I could change the animation of normal activities, but when i change the launchMode to singleInstance, the first time i open the activity, the animation come with Default. Then, every time i call it again, it come with the right custom animation.
I tried with window.attributes.windowAnimations, with just style/theme and also overridePendingTransition() and the result is always the same.
I saw some people with the same problem, but i coudnt find a solution that work.
Cancel ALL Animation on SingleInstance
Android animate to singleTask
Android’s overridePendingTransition and singleInstance
回答1:
I had the same problem. After reading the documentation about Task and back stack, everything becomes clear.
This is caused by fact, that launchMode singleInstance creates singleton activity in new task.
Note, task = set of activities with the same group id i. e. affinity. By default app activities have the same affinity i. e. app consists of single task.
Normally, transition animations are applied on activities within single task. It seems that first transition does not work due of new task initialization. While new task is not fully initialized, activity of this task is not created, thus you will see transition with blank screen.
来源:https://stackoverflow.com/questions/42144203/custom-animation-doesnt-work-on-singleinstance-activity