share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentShareFile = new Intent(Intent.ACTION_SEND);
File fileWithinMyDir = new File(getFilepath("document.pdf"));
if(fileWithinMyDir.exists()) {
intentShareFile.setType("application/pdf");
intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+getFilepath("document.pdf")));
intentShareFile.putExtra(Intent.EXTRA_SUBJECT, "Subject of the Email");
intentShareFile.putExtra(Intent.EXTRA_TEXT, "Body of the Email");
startActivity(Intent.createChooser(intentShareFile, "Share File"));
}
}
});
private String getFilepath(String filename) {
return new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/Download/" + filename).getPath();
}
希望这就是您要的