title: Why oncreate method called after startActivityForResult?
body: <p>In my application i want to select image from <code>Gallery</code> and set the image in <code>ListView</code>. In my ListView<code>I have 16 rows. So when ever item click in</code>ListView<code>open the gallery and set the image to</code>ListView<code>. But my problem is some times after</code>startActivityForResult()<code>,</code>oncreate()` method called. This is the onclick code</p>
  
  <pre><code>Intent intent = new Intent(
                              Intent.ACTION_PICK,
                              android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                      intent.setType("image/*");
                      startActivityForResult(
                              Intent.createChooser(intent, "Select File"),
                              SELECT_PICTURE);
  </code></pre>
  
  <p>And this is the onactivityresult</p>
  
  <pre><code>public void onActivityResult(int requestcode, int resultcode, Intent data) {
      Log.e("result", "result");
      displayMetrics = this.getResources().getDisplayMetrics();
      Ew = displayMetrics.widthPixels;
      Eh = displayMetrics.heightPixels;
  
      switch (requestcode) {
      case SELECT_PICTURE:
          if (resultcode == RESULT_OK) {
  
              lelListLayout.setVisibility(View.GONE);
              relImageLayout.setVisibility(View.VISIBLE);
  
  
              Uri selectedImageUri = data.getData();
              selectedImagePath = getPath(selectedImageUri);
  
              ExifInterface exif = null;
              // Bitmap bmRotated = null;
  
              try {
                  exif = new ExifInterface(selectedImagePath);
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
              int orientation = exif.getAttributeInt(
                      ExifInterface.TAG_ORIENTATION,
                      ExifInterface.ORIENTATION_UNDEFINED);
              Log.e("Orientation==&gt;", "" + orientation);
  
              try {
  
                  bmRotated = null;
                  bmGallayImage = null;
                  trimCache();
                  bmGallayImage = convertBitmap(selectedImagePath);
                  bmRotated = InventorySubmitImagesActivity.rotateBitmap(
                          bmGallayImage, orientation);
  
                  // if(bmRotated.getWidth()&gt;bmRotated.getHeight()){
                  if (bmRotated.getWidth() &gt; 1024) {
                      float x = 0;
                      x = 1024 / (float) bmRotated.getWidth();
                      // Log.e("x====","value "+x);
  
                      bmRotated = Bitmap.createScaledBitmap(bmRotated, 1024,
                              (int) (bmRotated.getHeight() * x), true);
                  }
                  /*
                   * }else{ if(bmRotated.getHeight() &gt; 1024){ float x=0;
                   * x=1024/(float)bmRotated.getHeight();
                   * Log.e("x====","value "+x);
                   * 
                   * bmRotated = Bitmap.createScaledBitmap(bmRotated,
                   * (int)(bmRotated.getWidth()*x), 1024, true); } }
                   */
  
  
                  Eh = Eh - ll_buttonlayout.getHeight();
  
  
                  float iw = bmRotated.getWidth();
                  float ih = bmRotated.getHeight();
  
  
  
                  float diff = Ew / iw;
  
                  float layoutwidth = Ew;
                  float layoutheight = diff * ih;
  
                  if (layoutheight &gt; Eh) {
  
                      diff = Eh / ih;
                      layoutwidth = Ew * diff;
                      layoutheight = Eh;
                  }
  
                  bmGallayImage = bmRotated;
                  if (bmRotated != null) {
  
                      RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                              (int) layoutwidth, (int) layoutheight);
                      relImage.setLayoutParams(layoutParams);
  
  
                      Drawable dr = new BitmapDrawable(bmRotated);
                      old_width = bmRotated.getWidth();
                      old_height = bmRotated.getHeight();
  
                      relImage.setBackgroundDrawable(dr);
  
                  }
                  left = (int) layoutwidth / 2 - 34;
                  top = (int) layoutheight / 2 - 8;
  
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              // drag_check=true;
              relImage.removeAllViews();
  
              imgMarker = new ImageView(this);
              final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                      RelativeLayout.LayoutParams.MATCH_PARENT,
                      RelativeLayout.LayoutParams.MATCH_PARENT);
              relImage.addView(imgMarker, layoutParams);
              imgMarker.setScaleType(ImageView.ScaleType.MATRIX);
              bmdragImage = BitmapFactory.decodeResource(getResources(),
                      R.drawable.image_marker);
              imgMarker.setImageBitmap(bmdragImage);
  
              matrix = new Matrix();
              savedMatrix = new Matrix();
              oldDist = 0f;
              start = new PointF();
              mid = new PointF();
  
              matrix.postTranslate(left, top);
              imgMarker.setImageMatrix(matrix);
  
              imgMarker.setOnTouchListener(RefurbishmentImageActivity.this);
              imgMarker.setVisibility(View.VISIBLE);
  
              // end..
              // }
  
          }
          break;
  </code></pre>
  
  <p>}
  }</p>
  
  <p>In this <code>ListView</code> after selecting 6 or 7 images oncreate method called, before the <code>onactivityresult()</code>. But after <code>oncreate()</code> method again startactivity result called. Please guide me what is the problem. Thanks InAdvance to all..</p>