Created
June 13, 2019 06:33
-
-
Save CodeK1988/08b46915782d241d3666cb4874561e6a to your computer and use it in GitHub Desktop.
Uri.fromFile error android 7.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Application | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); | |
StrictMode.setVmPolicy(builder.build()); | |
} | |
Uri uri; | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | |
uri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", file); | |
} else { | |
uri = Uri.fromFile(file); | |
} | |
just do it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment