Content uri crashes camera on Android KitKat

前端 未结 2 1650
醉梦人生
醉梦人生 2021-01-03 10:36

I run into problem while using content uri and FileProvider on Android API 19 (Kitkat). Here\'s code that I use to open camera on device and record a video:

         


        
相关标签:
2条回答
  • 2021-01-03 10:53

    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);
        }
    
    0 讨论(0)
  • 2021-01-03 11:00

    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.

    0 讨论(0)
提交回复
热议问题