android-access摄像头强制关闭api 29

android-access摄像头强制关闭api 29,android,android-camera,android-permissions,Android,Android Camera,Android Permissions,我试图从相机中捕获图像并将其存储在内存中,这是我的代码出错 它在安卓9之前版本上运行良好,但在安卓9+上崩溃 fileName = System.currentTimeMillis() + ".jpg"; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent

我试图从相机中捕获图像并将其存储在内存中,这是我的代码出错 它在安卓9之前版本上运行良好,但在安卓9+上崩溃

fileName = System.currentTimeMillis() + ".jpg";
                        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, getCacheImagePath(fileName));
                        if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
                            startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
                        }
private Uri getCacheImagePath(String fileName) {
    File path = new File(getExternalCacheDir(), "camera");
    if (!path.exists()) path.mkdirs();
    File image = new File(path, fileName);
    return getUriForFile(ImagePickerActivity.this, getPackageName() + ".fileprovider", image);
}
我已经授予相机和写入外部权限,我也在清单中定义了这些权限

堆栈不会返回任何错误(奇怪),这正是它不会进一步返回的行

takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, getCacheImagePath(fileName));

我该怎么办?

确切的路线?但问题的原因是什么?putExtra或获取Catch图像路径?将这些状态分开以找出。
getUriForFile
这是哪个类的函数?