0

我正在使用意图调用相机和 onresult 来获取捕获的图像,但如果没有拍摄图像(按取消),我想回到我调用相机的屏幕

我现在正在使用这个....但是有没有更好的方法来做到这一点:

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

        if (!(data == null || resultCode == 0)) {

            if (requestCode == CAMERA_REQUEST) {

                photo = (Bitmap) data.getExtras().get("data");
                imageView.setImageBitmap(photo);
            }
        } else {

            Intent intent = new Intent(ImageUploaderActivity.this,
                    ImageUploaderActivity.class);
            startActivity(intent);
            finish();
        }
    }
4

1 回答 1

1

我在我的应用程序中做类似的事情,这是我的代码:

    if (resultCode == RESULT_OK) {
        if (data != null) {
            //When all was ok
        }
    } else if (resultCode == RESULT_CANCELED) {
        //When it was canceled, when I press a back button while in camera app.
    } else {
        //Some other result
    }
于 2012-07-05T13:45:07.643 回答