@Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode != Activity.RESULT_OK) {
     return;
   }
   if (requestCode == REQUEST_DATE) {
     Date date = (Date) data.getSerializableExtra(DatePickerFragment.EXTRA_DATE);
     mCrime.setDate(date);
     updateDate();
   } else if (requestCode == REQUEST_CONTACT && data != null) {
     Uri contactUri = data.getData();
     String[] queryFields = new String[] {ContactsContract.Contacts.DISPLAY_NAME};
     Cursor c =
         getActivity().getContentResolver().query(contactUri, queryFields, null, null, null);
     try {
       if (c.getCount() == 0) {
         return;
       }
       c.moveToFirst();
       String suspect = c.getString(0);
       mCrime.setSuspect(suspect);
       mSuspectButton.setText(suspect);
     } finally {
       c.close();
     }
   }
   if (requestCode == REQUEST_TIME) {
     Date date = (Date) data.getSerializableExtra(TimePickerFragment.EXTRA_TIME);
     mCrime.setDate(date);
     updateTime();
   }
 }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) {
      return;
    } else if (requestCode == REQUEST_DATE) {
      Date date = (Date) data.getSerializableExtra(DatePickerFragment.EXTRA_DATE);
      mCrime.setDate(date);
      mCallbacks.onCrimeUpdated(mCrime);
      updateDate();
    } else if (requestCode == REQUEST_TIME) {
      Date date = (Date) data.getSerializableExtra(TimePickerFragment.EXTRA_TIME);
      mCrime.setDate(date);
      updateTime();
    } else if (requestCode == REQUEST_PHOTO) {
      // Create a new Photo object and attach it to the crime
      String filename = data.getStringExtra(CrimeCameraFragment.EXTRA_PHOTO_FILENAME);

      if (filename != null) {
        Photo p = new Photo(filename);
        mCrime.setPhoto(p);
        mCallbacks.onCrimeUpdated(mCrime);
        showPhoto();
      }
    } else if (requestCode == REQUEST_CONTACT) {
      Uri contactUri = data.getData();

      // Specify which fields you want your quwery to return
      // values for.
      String[] queryFields = new String[] {ContactsContract.Contacts.DISPLAY_NAME};

      // Perform your query - the contactUri is like a "where"
      // clause here
      Cursor c =
          getActivity().getContentResolver().query(contactUri, queryFields, null, null, null);

      // Double check that you actually got results
      if (c.getCount() == 0) {
        c.close();
        return;
      }

      // Pull out the first column of the first row of data -
      // that is your suspect's name.
      c.moveToFirst();
      String suspect = c.getString(0);
      mCrime.setSuspect(suspect);
      mCallbacks.onCrimeUpdated(mCrime);
      mSuspectButton.setText(suspect);
      c.close();
    }
  }