Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: access the Activity stack programmatically

is it possibile to get the current Activity stack from code?

Here is my use case:

  • the user navigates from Activity to Activity

A -> B -> c -> D -> ...

  • some of the Activity will finish after sending the user to the new screen, some others won't

  • I need to check if pressing the BACK button will bring the user to the Activity A or any other because in the currently shown Activity I have a button that finishes the Activity and the icon of the button is different weather you'll be taken to tha Activity A or another Activity.

Thanks in advance,

Bye, Maurizio

like image 761
Maurix Avatar asked Oct 08 '22 23:10

Maurix


1 Answers

My impression is that the answer to the literal question is "no" - you cannot access that. But there's probably another way to accomplish what you need.

If these are all your activities, why not put an extra in the Intent (when going in the forward direction) which says which activity it is coming from.

You can then decide which back button image to display based on checking that extra, which should tell you what the previous activity was (if it was one of yours - if it's empty you have to assume it came from somewhere else in the system)

like image 113
Chris Stratton Avatar answered Oct 12 '22 12:10

Chris Stratton