I'm trying to figure out a way to bring an existing activity to the front and clear all other activities. I think I can do this with Intent.setFlags(int flags) but I'm not certain which flags to use.
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT|Intent.FLAG_ACTIVITY_CLEAR_TOP);
I would think this would work, but it doesn't. It clears all activities including the one I'm trying to bring to the front. Is there a way to do this without clearing the activity I'm trying to bring to the front?
You should use these flags
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
It will clear the activity hierarchy and then create your new one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.