Android:如何重启实例?
我想重新启动我的活动的一个实例。是否可以?
例如,从一个活动,我将转到另一个活动,然后当我返回到上一个活动时,一切都是新的,不会保存任何实例。
我对安卓有点陌生。谢谢。
I want to restart an instance of my activity. Is it possible?
For example from an activity, I will go to another activity then when I go back to previous activity, all is new, no instance is saved.
I'm kinda new to android. thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这篇旧文章可以帮助您:how do i restart an android Activity
Maybe this old post could help you: how do i restart an android activity
我刚刚通过将这一行添加到我的 android 清单中解决了这个问题:
这是您声明您不想在每次启动一个意图时都实例化一个新活动。您现在可以重用现有活动。以下是 API 文档的链接,该文档解释了清单文件中的此项调整和其他活动调整:
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
这是一个老问题,但希望这个答案可以帮助那些仍在试图弄清楚这一点的人。
I just solved this by adding this line into my android manifest:
This is you declaring that you don't want to instantiate a new activity every time you start an intent of one. You can now reuse existing activities. Here's a link to the API document that explains this and other activity tweaks in the manifest file:
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
This is an old question but hopefully this answer can help people still trying to figure this out.