Open downloaded file on Android N using FileProvider

前端 未结 5 815
滥情空心
滥情空心 2021-02-05 17:11

I\'ve got to fix our App for Android N due to the FileProvider changes. I\'ve basically read all about this topic for the last ours, but no solution found did work out for me.

5条回答
  •  再見小時候
    2021-02-05 17:57

    Thanks to @greenaps I was able to solve the issue. The local URI retrieved from the DownlodManager was prefixed with file://. This has to be dropped for the new FileProvider:

    if (localUri.substring(0, 7).matches("file://")) {
        localUri =  localUri.substring(7);
    }
    File file = new File(localUri);
    

提交回复
热议问题