Please Guys ! I want to send MMS automatically without user interface as for SMS using this code :

 String messageToSend = "this is a message";
 String number = "2121234567";

 SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null,null);

This code works well for SMS but how can i do it for MMS please ?

有帮助吗?

解决方案

There is no public API to send the MMS without user interaction in android. You can find the code on the stackoverflow How to send image via MMS in Android?

But this still not the good way because it need the APN settings to send the MMS. For Android 4.0+ you can't get the APN Secure Settings in android. So I recommend to you to send the MMS using the Intent.

To send the MMS using Intent :-

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "some text"); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/image.png"));
sendIntent.setType("image/png");
startActivity(sendIntent);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top