微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何恢复暂停的Android应用程序(app not Activity)

如何将我的Android应用程序恢复到最后的位置,即视图中的活动等?如果我正在显示活动并按下主页按钮,然后再次启动我的应用程序,则返回启动活动.我希望它像iPhone应用程序一样工作,暂停到位并恢复到用户最后的位置.

谢谢.

解决方法:

您可能需要为清单中的根活动设置android:alwaysRetainTaskState =“true”.从文档:

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.

normally,
the system clears a task (removes all
activities from the stack above the
root activity) in certain situations
when the user re-selects that task
from the home screen. Typically, this
is done if the user hasn’t visited the
task for a certain amount of time,
such as 30 minutes.

However, when this
attribute is “true”, users will always
return to the task in its last state,
regardless of how they get there. This
is useful, for example, in an
application like the web browser where
there is a lot of state (such as
multiple open tabs) that users would
not like to lose.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐