Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Version used: androidx.fragment:fragment:1.2.0
Devices/Android versions reproduced on:
Calling FragmentManager toString() when it is not attached to an Activity crashes with NPE since mHost is null here:
@NonNull
@Override
public String toString() {
StringBuilder sb = new StringBuilder(128);
sb.append("FragmentManager{");
sb.append(Integer.toHexString(System.identityHashCode(this)));
sb.append(" in ");
if (mParent != null) {
Class<?> cls = mParent.getClass();
sb.append(cls.getSimpleName());
sb.append("{");
sb.append(Integer.toHexString(System.identityHashCode(mParent)));
sb.append("}");
} else {
Class<?> cls = mHost.getClass();
sb.append(cls.getSimpleName());
sb.append("{");
sb.append(Integer.toHexString(System.identityHashCode(mHost)));
sb.append("}");
}
sb.append("}}");
return sb.toString();
}
Originally detected with a dirty hack of dump()ing a Fragment to detect if it's in backstack or not, as in