After surfing through anything I could find in the Developer groups
and Google, I cannot find a solid, definitive answer to this question:
Is it possible to programmatically add attachments from internal
memory to emails in the Gmail app?
With the following snippet of code, I take the predefined String
"message" and attempt to write a file into internal memory through
FileStreamOutput and then attach this new file to an email:
FileOutputStream fos;
try { //Write our string into internal memory
to get a file
fos = this.openFileOutput(fileName,
Context.MODE_WORLD_READABLE);
fos.write(message.getBytes());
fos.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
//Get that file back from internal and attach
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(getFileStreamPath(fileName)));
Another post in this group claimed that this code had worked fine.
However, when looking through my device's log in DDMS (Devlik Debug
Monitor) I see the following error output from the Gmail app:
file:// attachment paths must point to file:///sdcard. Ignoring
attachment file:///data/data/mypackage/mydata.txt
This leads me to believe it is impossible to attach to an email from
internal memory. However, the previous post had given me hope that
there may be a solution. And furthermore, when the email is finally
brought up, the file name representing the file from internal memory
shows up on the attachment bar as though the file is actually
attached. However, when the email is sent out, the attachment no
longer appears in the email, indicating that it was never attached at
all.
Attaching a file from external memory was quite simple. This on the
other hand has been unnerving. Any ideas?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en