Listing 11.7 - Null Pointer Exception when swiping


#1

I have got a Null Pointer Exception when swiping fragments. Here is a fragment of the code:

....
public Fragment getItem(int pos) {
	UUID crimeId = (UUID) getIntent().getSerializableExtra(CrimeFragment.EXTRA_CRIME_ID);
	Crime crime = mCrimes.get(pos);
      for (int i=0;i<mCrimes.size();i++){
		  if(mCrimes.get(i).getId().equals(crimeId)){
		       mViewPager.setCurrentItem(i);
			break;				
			    }
			}	
				return CrimeFragment.newInstance(crime.getId());	
		}
   });
	}
}

any help is appreciated


#2

That is not the code that I see for Listing 11.7 in the book.


#3

oops, you are perfectly right, I misplaced some code!!
Thank you!!!