title: android finish sometimes restarting app
body: <p>I'm working on an app which allows user to choose a picture from gallery and then I start a activity to crop it.</p>
  
  <p>I want to send the cropped image back to calling activity.</p>
  
  <p>Both activities extend AppCompatActivity.</p>
  
  <p>Calling activity:</p>
  
  <pre><code>@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (resultCode == RESULT_OK) {
          if (requestCode == SELECT_PICTURE) {    
  
              // start image crop activity
              String dataString = data.getDataString();    
              Intent intent=new Intent(this, CropPhotoActivity.class);
              intent.putExtra("SELECTED_PICTURE_FOR_CROP", dataString);
              startActivityForResult(intent, CROP_PICTURE);    
          }
          else if(requestCode == CROP_PICTURE) {
              // get cropped bitmap
              Bitmap bitmap = (Bitmap) data.getParcelableExtra("CROPPED_IMAGE");
              profilePhoto.setImageBitmap(bitmap);
          }
      }
  }
  </code></pre>
  
  <p>In the crop image activity, I have a button, which on click should return back to calling activity:</p>
  
  <pre><code>Button okButton = (Button)findViewById(R.id.ok_button);
  okButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          Intent returnIntent = new Intent();
          returnIntent.putExtra("CROPPED_IMAGE", cropped_bitmap);
          setResult(RESULT_OK, returnIntent);
          finish(); // sometimes restarts app
      }
  });
  </code></pre>
  
  <p>Sometimes the bitmap gets returned correctly whereas sometimes it does not and the app gets restarted without error. Why is this happening? Does putExtra have anything to do with bitmap size or anything else?</p>