Search code examples
androidandroid-intentandroid-activityparentandroid-context

Android Parent Activity


Is there any way to get the parent activity instance for activities that are not embedded, the same way as for TabBar Activities you can use getParent()? Is there a method or a way to do the same for regular activities, started with a regular intent? I need to get the context, so I can pass it forward.


Solution

  • Is there any way to get the parent activity

    There is no concept of "parent activities" in Android, except in the now-deprecated ActivityGroup.

    I need to get the context, so I can pass it forward.

    First, each Activity is a Context. Second, passing Contexts around between component is a recipe for memory leaks. Please solve whatever problem you think you have in some other way.