Android Activity.getParent () always returns null

I have a small function here:

public Activity getRootActivity() { Activity a = this; while (a.getParent() != null) a = a.getParent(); return a; } 

But a.getParent () always returns null. It doesn't seem how deep I go into my interface, it will always return null.

Does anyone have an idea why?

EDIT

Here's how I get started (as part of other activities)

 startActivity(new Intent(this, activityname.class)); 

Apparently, this means that I am not โ€œembeddingโ€ them? How to "implement" it?

+8
android
source share
2 answers

The documentation says: public final Activity getParent () Since: API Level 1

Returns parent activity if this view is an inline child.

Is your activity a built-in child?

+10
source share

Activity#getParent() :

Returns parent activity if this view is an inline child.

Is the action a built-in child? If not, getParent() will return null.

+1
source share

All Articles