I'd like to warn the user if the back press is going to finish the last activity on the stack, thereby exiting the app. I'd like to pop up a little toast and detect a 2nd back press within the next few seconds and only then call finish()
.
I already coded the back press detection using onBackPressed()
, but I can't find an obvious way to see how many activities are left on the back stack.
Thanks.