Skip to content

Instantly share code, notes, and snippets.

@Sankame
Created July 23, 2018 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sankame/67c40ef8056fba82c23937e2ab54b161 to your computer and use it in GitHub Desktop.
Save Sankame/67c40ef8056fba82c23937e2ab54b161 to your computer and use it in GitHub Desktop.
File file = ...
// (1)
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// (2)
Uri uri = FileProvider.getUriForFile(
【アクティビティ名】.this
,getApplicationContext().getPackageName() + ".provider"
, file);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment