裁剪图像取消

时间:2011-11-28 14:58:15

标签: android

        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;
                        }
                    }
                } );

当我尝试取消裁剪图像时,我在Bundle extras = data.getExtras()中收到空指针异常;我该怎么做才能避免这个问题。这里有解决方案吗?

1 个答案:

答案 0 :(得分: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