I’ve noticed that FragmentActivity.activity can be...
# android
a
I’ve noticed that FragmentActivity.activity can be null, in what situation could this occur? Can the activity be destroyed without the destruction of the fragment?
a
I don't think so, but a fragment can be detached from an Activity. See https://stackoverflow.com/questions/6215239/getactivity-returns-null-in-fragment-function
g
Can the activity be destroyed without the destruction of the fragment
Sure! Fragment detached, Activity is destroyed. It’s completely valid case
s
FYI, requireActivity will throw an exception but otherwise always a non null return type