ImageView not refreshing/reflecting changes
<p>I'm using a photo picker intent to choose an image and write it to an application-private file. Most of my important source code is shown below. Once I press a button and perform the first image selection intent, then it successfully updates the image view. However, once I press the image selection button again (in the same activity), then the image view does NOT update, unless I exit and restart the activity. So I know the image is getting successfully saved, but why would the ImageView in the layout not refresh or update?</p>

<pre><code>public void onResume() {
    super.onResume();
    ImageView myImageView = (ImageView)findViewById(R.id.contact_image);
    if (hasImage) {
      myImageView.setImageURI(Uri.fromFile(getFileStreamPath(TEMP_PHOTO_FILE)));
    }
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case PHOTO_PICKED:
      if (resultCode == RESULT_OK) {
        if (data != null) {
          Bundle extras = data.getExtras();
          if (extras != null) {
            hasImage = true;
            bmp = (Bitmap) extras.get("data");
          }
        }
      }
      break;
    }
  }

  private OnClickListener mChooseImage = new OnClickListener() {
    @Override
    public void onClick(View v) {
      try {
        // Launch picker to choose photo for selected contact
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        intent.setType("image/*");
        intent.putExtra("crop", "true");
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", ICON_SIZE);  
        intent.putExtra("outputY", ICON_SIZE);
        intent.putExtra("scale", true);
        intent.putExtra("return-data", false);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile()));
        intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
        startActivityForResult(intent, PHOTO_PICKED);
      } catch (ActivityNotFoundException e) {
        // LOG THIS
      }
    }
  };

private File getTempFile() {
    try {
      if (!hasImage) {
        FileOutputStream fos = openFileOutput(TEMP_PHOTO_FILE, MODE_WORLD_WRITEABLE);
        fos.close();
      }
      return getFileStreamPath(TEMP_PHOTO_FILE);
    } catch (FileNotFoundException e) {
      // To be logged later
      return null;
    } catch (IOException e) {
      // To be logged later
      return null;
    }
  }
</code></pre>

<p>upon activity result, I set the ImageView's image URI to this file.</p>

<p>When it first completes, the ImageView changes to reflect this. However, if I attempt to choose the image again (same activity), the ImageView will not update until I exit and re-enter the activity. I'm not sure why this happens, is it because I'm trying to write to the temp.jpg everytime? Or do I need to refresh my layout somehow to reflect changes in the ImageView?</p>
