看到太多网上对7.0兼容,对于文件共享的限制。
Uri.fromFile(file) : file:///storage/emulated/0/DCIM/download/aaa.jpg
FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", file):content://com.taikang.simtest.fileProvider/camera_photos/DCIM/download/aaa.jpg
Uri.parse(file.getAbsolutePath()):/storage/emulated/0/DCIM/download/aaa.jpg
7.0对于直接由文件生成Uri这一方法并没有限制,如果把生成的Url用作发送通知什么的,并没有任何问题。
若是用于打开外部动作,则会在StrictMode.onFileUriExposed 校验失败,抛出FileUriExposedException异常