开发者

Android: How to restart an instance?

开发者 https://www.devze.com 2023-03-09 21:47 出处:网络
I want to restart an instan开发者_如何学编程ce 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 in

I want to restart an instan开发者_如何学编程ce 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.


Maybe this old post could help you: how do i restart an android activity


I just solved this by adding this line into my android manifest:

android:launchMode="singleInstance"

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消