开发者

How to navigate to a certain acticity in a chain without leaking memory

开发者 https://www.devze.com 2023-03-01 17:28 出处:网络
I have a user case like this: Activity A -> B -> C ->D. In the Activity D, I want to get开发者_C百科 back to the Activity A. I tried with Intent and it is okay, however, instead of reusing the exi

I have a user case like this:

Activity A -> B -> C ->D.

In the Activity D, I want to get开发者_C百科 back to the Activity A. I tried with Intent and it is okay, however, instead of reusing the existing one, it created a new one. Anyone please let me know how to cope it?

Thank a lot!


There is a fine topic on developer.android regarding exactly this question, check it out: avoiding memory leaks


You need to set the flags on the intent when you start A again

Intent i = new Intent(this, ActivityA.class); 
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(i);

see public Intent setFlags (int flags)

for reference

0

精彩评论

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

关注公众号