Skip to content

Instantly share code, notes, and snippets.

@markbratanov
Created May 30, 2015 18:29
Show Gist options
  • Save markbratanov/7580938c4e942d58892a to your computer and use it in GitHub Desktop.
Save markbratanov/7580938c4e942d58892a to your computer and use it in GitHub Desktop.
void onCreate (Bundle savedInstanceState) {
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("application/pdf".equals(type)) {
handlePDF(intent); // Handle text being sent
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if (type.startsWith("application/pdf")) {
// Handle multiple pdfs being sent
}
} else {
// Handle other intents, such as being started from the home screen
}
}
void handlePDF(Intent intent) {
Uri pdfUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (pdfUri != null) {
// TODO: Use your server-side here to save.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment