用户捕获图像时,如何检查当前在 android 中打开的相机 ID(主要或次要)?

How to check camera Id (primary or secondary) which camera is open currently in android when user capture an image?

如何在用户单击 android 中的图像时检查相机类型(主要或次要)?

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        fileUri = Utility.getOutputMediaFileUri(MEDIA_TYPE_IMAGE, mContext);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        startActivityForResult(intent, REQUEST_CAMERA);

您无法在此上下文中查看。该意图应该只是 return 捕获。如果您尝试使用 Camera.open() 打开另一个相机,您的应用程序将会崩溃。

您应该实现自定义相机捕获 activity,您可以在其中完全控制相机对象。然后检查使用了哪个相机对象。

How to check camera type(primary or secondary) when user clicks an image in android?

你不知道。图片就是图片。无论它是由前置摄像头、后置摄像头、USB 连接摄像头、IP 摄像头拍摄的,还是只是一些剪贴画,都取决于碰巧拍摄这张照片的相机应用程序。有数百种不同的相机应用程序,包括预装的和用户安装的。

如果返回的图片有EXIF header,你可以通过解析找到相机特征。最有可能的是,您将能够确定它是使用前置摄像头还是后置摄像头拍摄的。

后置摄像头的分辨率通常更高,您可以简单地检查照片分辨率是否符合这个要求。请注意,在大多数内置相机应用中,MediaStore.ACTION_IMAGE_CAPTURE Intent 不允许用户选择相机分辨率,因此照片将采用默认尺寸。