Problems with Android Fragment back stack

Explanation: on what’s going on here? If we keep in mind that .replace() is equal with .remove().add() that we know by the documentation: Replace an existing fragment that was added to a container. This is essentially the same as calling remove(Fragment) for all currently added fragments that were added with the same containerViewId and then … Read more

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