harshita
harshita

Reputation: 497

Send text and image in same message using SmsManager in android

I am working on an application which is sending text and image messages. I am sending Text and Image using SmsManager in my Application as below. The problem is, this is sending separate messages for every image and text I am sending thus not getting in exact order, but I want to send and get message in exact order.

final PendingIntent pendingIntent = PendingIntent.getBroadcast(
                        NewLeaveItemActivity.this, 0, new Intent(ACTION_MMS_SENT), 0);

SmsManager.getDefault().sendMultimediaMessage(getApplicationContext(),
                                mainImageContentUri, null, null,
                                pendingIntent);

                        SmsManager.getDefault().sendMultimediaMessage(getApplicationContext(),
                                qRCodeContentUri, null, null,
                                pendingIntent);

                        SmsManager.getDefault().sendMultimediaMessage(getApplicationContext(),
                                storeContentUri, null, null,
                                pendingIntent);

                        PendingIntent intent = PendingIntent.getBroadcast(
                                NewLeaveItemActivity.this, 0, new Intent(ACTION_MMS_RECEIVED), 0);

                        SmsManager.getDefault().sendTextMessage(mEditMobileNew.getText().toString().trim(), null, bellowMessage, pendingIntent, intent);

The Example message pattern i want, and i am getting

It wouldn't be a professional or better way to split the MMS into 2 or 3 parts and send them separately. There would be a better way so that we can control what order they are received in? Please help me.

Upvotes: 1

Views: 1896

Answers (2)

Jin Thakur
Jin Thakur

Reputation: 2773

Create one large mms message. Convert all sms into mms too. Api will automatically divide into multiple mms and will be in order. Don't use SMS all messages should be part of a big mms. method used here

divideMessage
Added in API level 4
public ArrayList<String> divideMessage (String text)
Divide a message text into several fragments, none bigger than the maximum SMS message size

.

sendMultipartTextMessage
Added in API level 4
public void sendMultipartTextMessage (String destinationAddress, 
                String scAddress, 
                ArrayList<String> parts, 
                ArrayList<PendingIntent> sentIntents, 
                ArrayList<PendingIntent> deliveryIntents)
Send a multi-part text based SMS. The callee should have already divided the message into correctly sized parts by calling divideMessage.

Upvotes: -1

Arunachalam k
Arunachalam k

Reputation: 744

use this amazing library to send media through sms https://github.com/klinker41/android-smsmms

Upvotes: 0

Related Questions