Content uri crashes camera on Android KitKat

旧街凉风 提交于 2019-11-30 16:06:27

Not every camera app will support content Uri values for EXTRA_OUTPUT, though they should. But, there are thousands of camera apps, and some percentage will fail on such a Uri. For example, until this summer, Google's own camera app did not support a content Uri for EXTRA_OUTPUT for ACTION_VIDEO_CAPTURE.

Either stop using ACTION_VIDEO_CAPTURE or live with unreliable results.

If you wish to try continuing to use file Uri values, drop your targetSdkVersion to 23 or lower, or disable the FileUriExposedException by changing the StrictMode configuration.

maybe you can try this one.

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT){
        fileUri = Uri.fromFile(mTmpFile);
    } else {
        fileUri = FileProvider.getUriForFile(getContext(),
                getContext().getPackageName()+".provider",mTmpFile);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!