5

我正在使用相机意图在我的应用程序中启动相机,但是一旦意图被触发,onActivityResult就会被触发,我什至还没有拍照。

当我拍照时,选择它并返回我的活动,onActivityResult根本不会被调用

这是我启动相机的方式

PackageManager pm = getPackageManager();
    if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        File tempDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),"Mobile Map");
        if (!tempDir.exists()) {
            if (!tempDir.mkdir()) {
                Toast.makeText(this,
                        "Please check SD card! Image shot is impossible!",
                        Toast.LENGTH_SHORT).show();
            }
        }

        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",Locale.US).format(new Date());
        File mediaFile = new File(tempDir.getPath() + File.separator+ "IMG_" + timeStamp + ".jpg");

        photoUri = Uri.fromFile(mediaFile);
        camera.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
        startActivityForResult(camera, CAMERA_REQUEST);
    } else {
        Toast.makeText(this,"This device does not have a rear facing camera",Toast.LENGTH_SHORT).show();
    }

为什么onActivityResult在相机意图启动后唯一被调用?

4

1 回答 1

5

问题是,在我的清单中,我将活动设置为singleInstance并且显然startActivityForResult不喜欢那样

于 2013-05-16T18:38:02.897 回答