Android Email Intent - Received file attachment is Zero bytes -
i setup email intent in app. attach binary file it. when email editor opens shows how many bytes. when receive email 0 bytes!
i have done on separate project , worked before copied code new project.
intent emailintent = new intent(android.content.intent.action_send); emailintent.settype("application/octet-stream"); emailintent.putextra(android.content.intent.extra_email, new string[] { "" }); emailintent.putextra(android.content.intent.extra_text, "message here"); emailintent.putextra(android.content.intent.extra_subject, "subject"); emailintent.putextra(intent.extra_stream, uri.parse("file:///data/data/com.example.app/files/filename.extension"));
i have tested on gingerbread , jelly bean. used default email editor of devices(galaxy y , htc one).
again received attachment 0 bytes if email editor shows bytes(i.e. 306 bytes)
-------update---------
so created project , tested code below. sends email attachment. when use same code on project email received 0 byte. can see tested if file object null , not null when ran.
file file = new file(file.getfilepath(context, "myfile.code")); intent emailintent = new intent(android.content.intent.action_send); emailintent.settype("message/rfc822"); emailintent.putextra(android.content.intent.extra_email, new string[] { "" }); emailintent.putextra(android.content.intent.extra_text, "blah...blah..."); emailintent.putextra(android.content.intent.extra_subject, "file sent"); emailintent.putextra(intent.extra_stream, uri.fromfile(file)); //i used file:///data/data/com.example.emailfile/files/myfile.code , didn't work if(file == null){ log.d("----file----", "null"); }else{ log.d("----file----", "not null"); }
this driving me crazy...any settings or setup did on project prevents attachment?
btw, activity running has radio buttons , button invoke email intent. i'm sending email either using gmail or outlook.
finally figured out.
first of course make sure file mode_world_readable.
second gmail seems don't have access internal storage or files within apps. also, discussed here http://code.google.com/p/android/issues/detail?id=18872
it managed send , attachment using outlook.
Comments
Post a Comment