سؤال

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

هل كانت مفيدة؟

المحلول

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)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top