title: Gallery(process com.cooliris.media) has stopped unexpectedly
body: <p>I am using either camera or gallery to take photos for my app.But sometimes after clicking images from camera and then switching to gallery ,gallery crashes. </p>
  
  <p>code is given below:</p>
  
  <pre><code>case R.id.etUploadImage:
          Log.d(TAG, " add photo");
          if (!Environment.getExternalStorageState().equals(
                  Environment.MEDIA_MOUNTED)) {
              Toast.makeText(getApplicationContext(), "sdcard not mounted",
                      Toast.LENGTH_SHORT).show();
              break;
          }
          AlertDialog.Builder photoDialog = new AlertDialog.Builder(this);
          photoDialog
                  .setTitle("Photo source")
                  .setCancelable(true)
  
                  .setPositiveButton("Open Gallery",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog,
                                      int id) {
                                  startActivityForResult(
                                          new Intent(
                                                  Intent.ACTION_PICK,
                                                  android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI),
                                          54);
                              }
                          })
  
                  .setNegativeButton("Open Camera",
                          new DialogInterface.OnClickListener() {
  
                              public void onClick(DialogInterface dialog,
                                      int id) {
                                  //String fileName = "temp.jpg";
                                  Date date = new Date();
                                  DateFormat df = new SimpleDateFormat("-mm-ss");
  
                                  String newPicFile = "Bild"+ df.format(date) + ".jpg";
                                  String outPath = "/sdcard/" + newPicFile;
                                  File outFile = new File(outPath);
  
                                  ContentValues values = new ContentValues();
                                  values.put(MediaStore.Images.Media.TITLE,
                                          outFile.getAbsolutePath());
                                  mCapturedImageURI = getContentResolver()
                                          .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                                                  values);
  
                                  Intent intent = new Intent(
                                          MediaStore.ACTION_IMAGE_CAPTURE);
                                  intent.putExtra(MediaStore.EXTRA_OUTPUT,
                                          mCapturedImageURI);
  
                                  startActivityForResult(intent, 96);
  
                              }
                          });
          photoDialog.show();
          break;
      }
  </code></pre>
  
  <p>and onActivityResult() is:</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == 54 &amp;&amp; resultCode == RESULT_OK) {
          if(data !=null){
          fileName = getRealPathFromURI(data.getData());
          mUploadImage.setText(getStringNameFromRealPath((String) fileName));
          } else {
              Toast.makeText(getApplicationContext(),"Please select another image.", Toast.LENGTH_SHORT).show();
          }
      } else if (requestCode == 96 &amp;&amp; resultCode != 0) {
          String[] projection = { MediaStore.Images.Media.DATA };
          Cursor cursor = managedQuery(mCapturedImageURI, projection, null,
                  null, null);
          int column_index_data = cursor
                  .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
          cursor.moveToFirst();
          fileName = cursor.getString(column_index_data);
          String s[] = fileName.split("/");
          mUploadImage.setText(s[s.length - 1]);
          sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mCapturedImageURI));
      }
  }
  </code></pre>
  
  <p>What is making gallery to crash.Please help me.</p>