看到太多網上對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異常