Can't send attachments from application
I am trying to send a PDF from my application but when I tap "Send" it does not get attached it seems. I can see the icon for the file in the mail application though.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, mailSubject);
intent.putExtra(Intent.EXTRA_TEXT开发者_JAVA百科, mailMessage);
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///android_asset/download_l.pdf"));
The type should be "application/pdf" rather than "message/rfc822"
From the ACTION_SEND documentation:
Input: getType() is the MIME type of the data being sent. get*Extra can have either a EXTRA_TEXT or EXTRA_STREAM field, containing the data to be sent. If using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it should be the MIME type of the data in EXTRA_STREAM. Use / if the MIME type is unknown (this will only allow senders that can handle generic data streams).
In addition, I don't think you can attach something directly from your assets. I believe you have to copy to the SD card first and then send it from there
精彩评论