2011-11-28 95 views
0
 case CROP_FROM_CAMERA:   
         if(mImageCaptureUri!=null){ 
         Bundle extras = data.getExtras(); 

         if (extras != null) {    
          Bitmap photo = extras.getParcelable("data"); 
          bmp = photo; 
         } 
builder.setOnCancelListener(new DialogInterface.OnCancelListener() { 
        @Override 
        public void onCancel(DialogInterface dialog) { 

         if (mImageCaptureUri != null) { 
          getContentResolver().delete(mImageCaptureUri, null, null); 
          mImageCaptureUri = null; 
         } 
        } 
       }); 

當我嘗試Cancell裁剪圖像時,我收到空指針異常Bundle extras = data.getExtras();我應該在這裏做什麼來避免這個問題。這裏有解決方案嗎?裁剪圖像取消

回答

0

您還可以得到一個結果代碼,它告訴你,如果它去好了:

protected void onActivityResult(int requestCode, int resultCode, 
     Intent data) { 
    if(requestCode == CROP_FROM_CAMERA){ 

     if (resultCode == Activity.RESULT_OK){ 
      // do stuff when you've got a result 
     } else{ /* canceled code here */ } 

田田! :D