Method invocation highlighed error in Android Studio
From what I've seen, Android Studio shows a bit too much warnings about potential NullPointerExceptions
, even for methods that will never return null. I simply ignore some of them, but it's useful to carefully check all of them, because sometimes I missed an important one.
If you look at the android source code, it's easy to see that getFragmentManager()
will never return null :
public FragmentManager getFragmentManager() {
return mFragments;
}
Where mFragments is assigned only once through the whole class :
final FragmentManagerImpl mFragments = new FragmentManagerImpl();