3

I want to attach image from resource/drawable folder to MMS.Is it possible to attach image from drawable folder to MMS.if yes then please provide me some code here.I tried a lot and also found a lot here on So as well as on Google but still not able to get the right solution yet.Please some one help me for my this issue.Thanks in Advance.My code is as:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("image/png");
        sendIntent.putExtra("sms_body",
                getResources().getText(R.string.Message));

        File f = new File(Environment.getExternalStorageDirectory()
                .getAbsolutePath(), "koala.jpg");

        Uri uri = Uri.fromFile(f);
        sendIntent.putExtra(Intent.EXTRA_STREAM, uri);

        startActivity(Intent.createChooser(sendIntent, ""));
Biginner
  • 243
  • 1
  • 2
  • 15

1 Answers1

3

You can achive this in following steps

First get the bitmap of image from your drawable

Then save that bitmap to SDcard

Then give that sdCard file path to you sendIntent

Community
  • 1
  • 1
Ali Imran
  • 8,927
  • 3
  • 39
  • 50
  • but i dont want to store that image in SD Card.I just want to attach image to MMS directly from drawable.is it possible to attach image from drawable folder? – Biginner Dec 11 '12 at 10:50
  • I this it is not possible for android current implementation. may be in future :) – Ali Imran Dec 11 '12 at 10:52
  • if i want to attach image from URL MMS then What should i have to do? – Biginner Dec 11 '12 at 11:20
  • well i am attaching image from drawable folder to email successfully but why its not possible to MMS?Any Specific Reason behind that? – Biginner Dec 11 '12 at 11:27
  • 1
    If you want to attach a image from url then first download that image on sdCard then send the file path. here is some help how to download the image from URL :-http://stackoverflow.com/questions/3328898/load-image-from-url-in-android-only-if-small – Ali Imran Dec 11 '12 at 11:30
  • have you tried like this `Uri path = Uri.parse("android.resource://your.package.name/" + R.drawable.sample_1);` – Ali Imran Dec 11 '12 at 11:33
  • Then you need to implement the above solution. – Ali Imran Dec 11 '12 at 11:39
  • you mean to say i have to Store image in SD Card? – Biginner Dec 11 '12 at 11:58
  • No, just temporary copy the image from your `drawable` folder to `SdCard` and after sending the MMS you can delete that image. – Ali Imran Dec 11 '12 at 12:01
  • do you know how to delete file from SD Card after MMS set Successfully.I tried it with filepath.delete but this code delete file before sending file to Receiver.Any suggestion regarding this problem? – Biginner Dec 12 '12 at 07:12
  • You have no strict need of deleting file just overwrite the existing file when sending a new MMS and in this way you always have one file on sdcard, and that is not a big deal :) – Ali Imran Dec 12 '12 at 07:16
  • but i dont want to saw this file to User in SD card. – Biginner Dec 12 '12 at 07:19
  • there are more than 20 file i am storing in SD card that's why i have to delete each file.please help me for this. – Biginner Dec 12 '12 at 07:25
  • here is the help to implement the delete operation :-http://stackoverflow.com/questions/8922714/how-to-delete-a-file-folder-in-a-sdcard-under-android-platform – Ali Imran Dec 12 '12 at 07:27
  • i store that image to SD Card it works perfectly on all devices except galaxy S3.i cannot able attach file from the SD card to MMS because there is no SD card in Galaxy S3 for that what should i have to do?Help me for this.hanks in Advance – Biginner Dec 20 '12 at 07:40
  • You can use internal memory to store the images. – Ali Imran Dec 20 '12 at 07:45
  • but i don't know how to store that audio file to internal memory of galaxy S3.Can you please help me for this? – Biginner Dec 20 '12 at 07:50
  • get help from here :-http://stackoverflow.com/questions/5017292/android-create-file-on-internal-storage – Ali Imran Dec 20 '12 at 08:24
  • is there any permission i have to give to access the file from the internal Memory? – Biginner Dec 20 '12 at 09:41
  • this is for writing external storage :-`` – Ali Imran Dec 20 '12 at 11:06
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/21453/discussion-between-ali-imran-and-romil) – Ali Imran Dec 20 '12 at 12:12
  • attach audio file to MMS Successfully to all devices Except Samsung galaxy S2,Naxus etc.How to solve this problem? – Biginner Dec 26 '12 at 11:56