my Android 4+ app can create different reports in PDF format. Know I would like to offer the user the option to send the file via mail or to open in any app that can handle PDF files. Currently I use the following code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("application/pdf");
Uri uri = Uri.parse("file://" + reportFile.getAbsolutePath());
intent.putExtra(Intent.EXTRA_STREAM, uri);
try {
startActivity(Intent.createChooser(intent, "Share PDF file"));
} catch (Exception e) {
Toast.makeText(ReportsActivity.this, "Error: Cannot open or share created PDF report.", Toast.LENGTH_SHORT).show();
}
This workes fine, except only "send" apps are offerd like Bluetooth, Google Drive, E-Mail, etc. I installed the Acrobat Reader app which can of course view PDF files. But this app as well is only listed with "Send for signature" and not with "Open in Reader" or somthing like this.
I thought the ACTION_SEND
intent would mean "send to other app" and not striktly "send somewhere else". What Intent can I use to include "open with" options as well?
ACTION_VIEW
is for viewing files.No,
ACTION_SEND
is for sending things. That includes "send to yourself in another app" in some cases (e.g., sending to Google Drive), but it specifically is not for viewing files.