How to prevent multiple instances of an Activity when it is launched with different Intents

Add this to onCreate and you should be good to go: // Possible work around for market launches. See https://issuetracker.google.com/issues/36907463 // for more details. Essentially, the market launches the main activity on top of other activities. // we never want this to happen. Instead, we check if we are the root and if not, we … Read more

Clear the entire history stack and start a new activity on Android

In API level 11 a new Intent Flag was added just for this: Intent.FLAG_ACTIVITY_CLEAR_TASK Just to clarify, use this: Java intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Kotlin intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK Unfortunately for API lvl <= 10, I haven’t yet found a clean solution to this. The “DontHackAndroidLikeThis” solution is indeed pure hackery. You should not do … Read more