Looking closer at the error messages, it looks like Android was failing
to get the correct Content Provider for opening a stream to http (maybe
there is none
available).
My work around was to download the image to the file system and load from
there.
Code below.
try{
java.net.URI uri = URI.create("
http://images.google.com/images/logo_sm.gif");
InputStream iStream = uri.toURL().openStream();
File image = new
File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/
logo_sm.gif <http://images.google.com/images/logo_sm.gif>");
FileOutputStream oStream = new FileOutputStream(image);
int c;
while ((c = iStream.read()) != -1) {
oStream.write(c);
}
iStream.close();
oStream.close();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_TEXT, "Email Text");
email.putExtra(Intent.EXTRA_SUBJECT, "Email Subject");
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
email.setType("image/gif");
startActivity(email);
}
catch (FileNotFoundException e) {
Log.e("ClassName",e.getMessage());
}
catch (IOException e) {
Log.e("ClassName",e.getMessage());
}
On Fri, Jul 3, 2009 at 1:02 AM, Don Oleary <[email protected]> wrote:
> Hi guys
>
> Apologies if this question has been asked before. I have found numerous
> threads with the same
> question, but have never found a satisfactory answer.
>
> I am trying to send an attachment through email. When composing the email,
> everything looks great (attachment
> seems to be included and ready to send). However, the attachment does not
> get received on the other side.
>
> Below is my code example
>
> Intent email = new Intent(Intent.ACTION_SEND);
> email.putExtra(Intent.EXTRA_TEXT, "Email Text");
> email.putExtra(Intent.EXTRA_SUBJECT, "Email Subject");
> email.putExtra(Intent.EXTRA_STREAM, Uri.parse("
> http://images.google.com/images/logo_sm.gif"));
> email.setType("image/gif");
> startActivity(email);
>
>
> Regards
> Don
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---