I have an application that generates a pdf from an internal content.
I need to share this pdf
, and for this I do the following:
final String filePath = file.getAbsolutePath();
final Uri arquivo = Uri.parse( filePath);
final Intent _intent = new Intent();
_intent.setAction(Intent.ACTION_SEND);
_intent.putExtra(Intent.EXTRA_STREAM, arquivo);
_intent.putExtra(Intent.EXTRA_TEXT, "Meu PDF");
_intent.putExtra(Intent.EXTRA_TITLE, "Meu pdf");
_intent.setType("application/pdf");
startActivity(Intent.createChooser(_intent, "Compartilhar"));
Being the variable arquivo
a Uri
, with the path of the file, which is generated when you open the screen.
The intent is called after the user click.
When I try to send by email, the file is not attached.
Displays a Toast saying that it is not possible to attach an empty file.
But when I go to the folder, it opens normally!
How do I get this pdf to share?