如何恢复暂停的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.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...