Android onActivityResult 没有为相机激活?

Android onActivityResult doesn't activate for the camera?

我试图通过 android 学习如何使用相机,但出于某种原因,相机完成后照片无法加载。 我在视图中有 2 个按钮和一个图像,1 个用于相机,1 个用于加载图片,但我想在没有按钮的情况下加载图片。(两个按钮都可以正常工作,onActivityResult 似乎不起作用)

static final int CAM_REQUEST = 1;
button = (Button) findViewById(R.id.button);
        imageView = (ImageView) findViewById(R.id.imageView);
        Button button2 = (Button) findViewById(R.id.button3);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                File file = getFile();
                camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
                startActivityForResult(camera_intent , CAM_REQUEST);
            }
        });

button2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String path = "sdcard/camera_app/cam_image.jpg";
                imageView.setImageDrawable(Drawable.createFromPath(path));

            }
        });

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

    String path = "sdcard/camera_app/cam_image.jpg";
    imageView.setImageDrawable(Drawable.createFromPath(path));
}

如你所见,button2 的代码与 onActivityResult 相同,但按钮加载图片而 onActivityResult 不加载图片..

在onActivityResult()中调用super

它应该是这样的:

 super.onActivityResult(requestCode, resultCode, data);