I'm not sure of the best way to do this; but my understanding of the
mechanism is that the image is pulled from any given content provider
URI, just so long as the data returned can be understood by
BitmapFactory.decodeStream().

So a simple solution would be to create a new ContentProvider and pass
a corresponding URI to the Intent (instead of
"content://content/external/images/..."). You could then send a
drawable from your app using this custom content provider in the form
of a ByteArrayOutputStream.

A second approach would be to copy the drawable image to the external
storage, and use the URI format I gave in the example.


On Mon, Jun 14, 2010 at 10:57 AM, Neilz <[email protected]> wrote:
> I've just been looking for something like this myself... a timely
> topic.
>
> Please could you edit this code to show how I would send an image from
> the @drawable folder?
>
> On Jun 9, 4:29 pm, Sean Hodges <[email protected]> wrote:
>> Mike,
>>
>> I can do a little more than that, I can give you a fully working unit
>> test with the phone number pre-populated in the From: field:
>>
>> package com.seanhodges.sandbox;
>>
>> import android.content.Intent;
>> import android.net.Uri;
>> import android.test.AndroidTestCase;
>>
>> public class SendAnMMS extends AndroidTestCase {
>>
>>         public void testSendingAnMMS() throws Exception {
>>                 Intent intent = new Intent(Intent.ACTION_SEND);
>>                 intent.putExtra("address", "12345");
>>                 intent.putExtra("sms_body", "See attached picture");
>>
>>                 intent.putExtra(Intent.EXTRA_STREAM,
>> Uri.parse("content://media/external/images/thumbnails/0"));
>>                 intent.setType("image/png");
>>
>>                 // This is added just so the AndroidTestCase launches the 
>> activity
>> as expected, remove this line in your production code
>>                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
>>
>>                 getContext().startActivity(intent);
>>         }
>>
>> }
>>
>> If the referenced image does not exist, you should get a warning
>> pop-up when the SMS app launches.
>>
>> On Wed, Jun 9, 2010 at 3:57 PM, mike <[email protected]> wrote:
>> > Hi Sean,
>>
>> > didn't get it at all. can you give me an example??
>>
>> > regards,
>> > Mike
>>
>> > --
>> > 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
>>
>>
>
> --
> 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

-- 
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

Reply via email to