title: Android camera, save image then display the image
body: <p>I'm trying to take an image, store the filpath in a global variable, and then display a thumbnail. But it fails to display the image after the image has been saved. </p>
  
  <p>Fails at:</p>
  
  <pre><code>startActivityForResult(takePicture, 0);
  </code></pre>
  
  <p>//</p>
  
  <pre><code>    //Camera Application For new Photo
  public void btnPhotoClicked(View v) {
  
      Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  
      //Create the file path
      File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
      String pictureName = getPictureName();
      File imageFile = new File(pictureDirectory, pictureName);
      Uri pictureUri = Uri.fromFile(imageFile);
  
      //set the filepath to a global variable
      imgurl = pictureUri.toString();
  
  
      //save the picture
      takePicture.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
  
  
      //start the activity
      startActivityForResult(takePicture, 0);//zero can be replaced with any action code
  
  }
  </code></pre>
  
  <p>Here is the display function, which separates from take photo and pick photo</p>
  
  <pre><code>    protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
      super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
      switch(requestCode) {
          case 0:
              if(resultCode == RESULT_OK){
  
                  Uri selectedImage = imageReturnedIntent.getData();
                  //Set the thumbnail
                  mImageView.setImageURI(selectedImage);
  
                  //set a textfield to the filepath
                  tximgurl.setText(imgurl);
  
  
              }
  
              break;
          case 1:
              if(resultCode == RESULT_OK){
                  Uri selectedImage = imageReturnedIntent.getData();
                  mImageView.setImageURI(selectedImage);
  
                  tximgurl.setText(imgurl);
              }
              break;
      }
  
  }
  </code></pre>