使用android中的SmsManager在同一消息中发送文本和图像

问题描述 投票:1回答:2

我正在开发一个正在发送文本和图像消息的应用程序。我在我的应用程序中使用SmsManager发送文本和图像,如下所示。问题是,这正在为我发送的每个图像和文本发送单独的消息,因此发送的顺序不正确,但是我想按照正确的顺序发送和获取消息。

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

将MMS分为2或3部分,然后分别发送,这不是一种专业或更好的方法。会有更好的方法,以便我们可以控制接收它们的顺序?请帮我。

android smsmanager
2个回答
0
投票

使用这个令人惊叹的库通过短信发送媒体https://github.com/klinker41/android-smsmms


0
投票

创建一个大彩信。也将所有短信转换为彩信。Api将自动划分为多个mm,并且顺序良好。不要使用SMS,所有消息都应该是大消息的一部分。这里使用的方法

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.
© www.soinside.com 2019 - 2024. All rights reserved.