我正在使用相机意图在我的应用程序中启动相机,但一旦意图被触发,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?
最佳答案
问题是,在我的清单中,我将活动设置为singleInstance,显然startActivityForResult不是那样的
原文链接:https://www.f2er.com/android/430862.html