5

The below code is navigating me too default MMS app with the photo, text and number

Intent mmsIntent = new Intent(Intent.ACTION_SEND);
mmsIntent.putExtra("sms_body", "text");
mmsIntent.putExtra("address", "121");
mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "photo.jpeg")));
mmsIntent.setType("image/jpeg");
mmsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mmsIntent);

What I need is to send mms in background without showing any kind of interface. I can send text sms using SmsManager using

SmsManagaer smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(num, null, "Help Me", null, null);

Can I use smsManager.sendMultimediaMessage() to send mms(I'd tried this method and no success yet)? If not then what it's use? And is there any other way to send mms in background?

4

1 回答 1

3

您正在做的是创建隐式意图,它将根据您发送的操作启动另一个应用程序。如果安装了多个应用程序并在意图过滤器中注册了操作,它可能会显示选择器对话框。

要在没有用户交互的情况下发送彩信,您可以使用smsManager.sendMultimediaMessage()发送彩信,但这种方法是从 API 版本 21 开始引入的。您可以参考此处的演示以了解如何使用sendMultimediaMessage().

要支持之前的版本,您可以集成此答案中列出的解决方案。

于 2016-06-14T11:19:12.927 回答