A. K. M. Tariqul Islam
A. K. M. Tariqul Islam

Reputation: 2834

Clear activity stack without using startActivity()

Simple question: How can I clear Activity stack keeping current one?

I have a LoginActivity, HomeActivity and 100 more activities. I come to HomeActivity from 101 activities. I can clear activity stack

  1. while calling startActivity() from those 101 activities using intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
  2. in the HomeActivity, only once

I want to do the 2nd. Is it possible? If yes, how? I want to clear activity stack to free resources.

Upvotes: 1

Views: 828

Answers (1)

am110787
am110787

Reputation: 316

Add android:clearTaskOnLaunch="true" and android:launchMode="singleTask" in your HomeActivity manifest tag.

Upvotes: 3

Related Questions