So, I have a feature in PreferencesActivity and I need to get the previous activity, which is still running, e.g. when you access directly the preferences while still at this same activity. So it is still alive.
I tried through casting and context, which would be have been useful, if I had any other except AplicationContext
and BaseContext
.
So is there a way to get the previous activity from preferences activity?
which is still running
Not necessarily. The user can press HOME (or switch to another task via the overview screen), then return to your app several minutes later. If your process was terminated in the meantime, the user will be returned to a newly-created instance of your preference activity, but none of your other activities will be running.
This is why communication between activities is loosely coupled.
So is there a way to get the previous activity from preferences activity?
Nothing that is supported and will work all of the time.