当前位置: 动力学知识库 > 问答 > 编程问答 >

Flow change on Home button press when opening app from APP Tray or from Recent app in Android?

问题描述:

Why Android apps act differently when opening app from application icon and opening from Recent apps (after exiting application by pressing Home button)?

Example : Start Activity A -> Activity B then press home button.

  1. Opening application from app icon will take you back to Activity A.

  2. Opening application from recent apps will take you to Activity B.

网友答案:

Setting attribute "android:alwaysRetainTaskState" to "true" will solve this problem as this will retain the state of the activity as it is. It doesn't allow system to reset activity state.

"android:alwaysRetainTaskState

Whether or not the state of the task that the activity is in will always be maintained by the system — "true" if it will be, and "false" if the system is allowed to reset the task to its initial state in certain situations. The default value is "false". This attribute is meaningful only for the root activity of a task; it's ignored for all other activities."

分享给朋友:
您可能感兴趣的文章:
随机阅读: