I am at a loss for this. I am switching tabs manually in my ViewPager. I have this code inside my Activity:
@Override
public void onBackPressed()
{
if (c
This one was a real brain twister for me. We removed all of the code that replaced the Fragment
s and kept the same fragments for the entire lifecycle of the Activity
and still had this problem. It wasn't until we viewPager.setOffscreenPageLimit(TABS);
where TABS
is the number of tabs (in our case 4) that we stopped getting the referenced NullPointerException
.
FWIW -- I'm pretty sure the problem is in Google's code. We couldn't get this to fail on a Nexus 5 running Lollipop, but it fails across Samsung devices running Kitkat. When I traced through the error itself, it looked like the failure happens because the Fragment
being referenced has already gone through the internal Fragment.initState
function because the Fragment
's id
is -1.