When I start the app everything works ok but when I rotate to landscape it crashes because in the Fragment
there is a field that is NULL
.
I don
this.mFragments = new ArrayList<>();
Because this is wrong. You should never hold a reference to the fragment list if you are using ViewPager. Just return new instance of Fragment from getItem(int position)
of FragmentPagerAdapter
and you are good to go.
But to fix your code, you must delete mFragments
entirely.
See https://stackoverflow.com/a/58605339/2413303 for more details.