How to check if an activity is the last one in the activity stack for an application?
I’m going to improve on the comment of @H9kDroid as the best answer here for people that have a similar question. (Original link) You can use isTaskRoot() to know whether the activity is the root of a task.