Skip to content

Instantly share code, notes, and snippets.

@CodeK1988
Created June 13, 2019 06:33
Show Gist options
  • Save CodeK1988/08b46915782d241d3666cb4874561e6a to your computer and use it in GitHub Desktop.
Save CodeK1988/08b46915782d241d3666cb4874561e6a to your computer and use it in GitHub Desktop.
Uri.fromFile error android 7.0
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