0

My question is the same as this one, but it is old and the accepted answer uses depreciated permissions and values. I would like an updated answer that works above API 21.

I need to override a home-screen return button action under certain conditions. (App is removed from stack by user, but widget launches an activity that requires now forgotten backwards navigation, so the backpress should launch new activity intent if this is so, but can't just check if widget opens the activity because it works as intended if user doesn't close the app manually.)

Mr.Drew
  • 939
  • 2
  • 9
  • 30
  • 1
    Closed as duplicate. The accepted answer in the linked question uses deprecated API. However, the answer with the most upvotes is the correct answer and doesn't use any deprecated API. – David Wasser Oct 08 '18 at 12:36
  • @DavidWasser I see now, thanks. Is there anyway to have the community update old answers accepted to current standards when the OP already accepted the answer for when standards change or methods depreciated? (Besides scrolling through and looking at votes or making duplicate questions?) – Mr.Drew Oct 09 '18 at 06:31
  • See https://meta.stackexchange.com/questions/5408/what-is-the-etiquette-for-correcting-old-questions-with-incorrect-answers – David Wasser Oct 09 '18 at 09:17

1 Answers1

1

If you want to check whether the current activity is last, you can use isTaskRoot() inside your activity to check whether this is the last activity.

Checkout more info on official link: https://developer.android.com/reference/android/app/Activity#isTaskRoot()

Mayur Gajra
  • 8,285
  • 6
  • 25
  • 41