0

With help from a few SO posts, I can successfully send multipart messages. However, I'm not finding anything about how to attach an image.

The crux of my code is:

SmsManager sms = SmsManager.getDefault();
ArrayList<String> parts = sms.divideMessage (message);
sms.sendMultipartTextMessage (phoneNumber, null, parts, sentIntents, null);

where message is a String. Note that I'm also using sentIntents and aBroadcastReceiver to get confirmations that each part is sent. I'm leaving that code out to keep this short.

What do I need to add for attaching an image?

Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
  • That method does not support images. It is strictly for text messages. – Mike M. Apr 27 '18 at 00:20
  • So, using SmsManager, is there a way to do it? Or do I have to go directly to http? I have found a few old SO posts, e.g. https://stackoverflow.com/questions/2972845/how-to-send-image-via-mms-in-android but am not sure what is supported today. – Peri Hartman Apr 27 '18 at 00:26
  • Well, since API level 21, `SmsManager` has had the [`sendMultimediaMessage()` method](https://developer.android.com/reference/android/telephony/SmsManager.html#sendMultimediaMessage(android.content.Context,%20android.net.Uri,%20java.lang.String,%20android.os.Bundle,%20android.app.PendingIntent)), but it's not as easily implemented as the text methods. [Example](https://github.com/aosp-mirror/platform_development/blob/master/samples/ApiDemos/src/com/example/android/apis/os/MmsMessagingDemo.java). Before that, yeah, you'd have to do something like is shown in your link, or use a library. – Mike M. Apr 27 '18 at 00:34
  • ok, thanks. Since I want my app to run on pre-API 21, I guess I need to use http directly. Hopefully, I can make sense of the examples :) – Peri Hartman Apr 27 '18 at 00:43

0 Answers0