Fixed
Status Update
Comments
la...@gmail.com <la...@gmail.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
il...@google.com <il...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
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