Android SDK 彩信
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1914456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android SDK MMS
提问by user160231
Does anyone know how to programmatically send a MMS via the Android SDK? Any version of the SDK will do, just need to know where to get started. I know how to send / receive SMS, I now need to add a picture to the message before sending.
有谁知道如何通过 Android SDK 以编程方式发送彩信?任何版本的 SDK 都可以,只需要知道从哪里开始。我知道如何发送/接收短信,我现在需要在发送前在消息中添加图片。
回答by Billy Bob Bain
This worked for me.
这对我有用。
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
The url being passed to the Uri.parse method should be of the form used to access the media store such as content://media/external/images/media/23.
传递给 Uri.parse 方法的 url 应该采用用于访问媒体存储的形式,例如 content://media/external/images/media/23。
From the series at jtribe.
来自jtribe的系列。
回答by Sumit Sharma
For Sending an MMS is Android is as simple just like we send an SMS.
Here is the Code Snippet.
发送彩信是 Android 就像我们发送短信一样简单。
这是代码片段。
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","7404357000");
i.putExtra("sms_body","hello..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("image/png");
startActivity(i);
Here Uri is:
Uri uri = Uri.parse("content://media/external/images/media/1");
or
Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");
or
Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("地址","7404357000");
i.putExtra("sms_body","你好..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("图片/png");
开始活动(i);
这里的 Uri 是:
Uri uri = Uri.parse("content://media/external/images/media/1");
或
Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");
或
Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");
Make sure that "test.jpg" is present or available in the SD Card.
You also need to give the permission in the Manifest file.
确保“test.jpg”在 SD 卡中存在或可用。
您还需要在 Manifest 文件中授予权限。
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Here is the final Output on Emulator.
This code also work fine on Device
这是模拟器上的最终输出。
此代码在设备上也能正常工作
Here is the link
这是链接
回答by Adrian
I'd love to get an answer to this one myself. It seems like a gaping hole in the API right now, and it's ridiculous that SMS is supported but MMS is not.
我很想自己得到这个问题的答案。现在这似乎是 API 中的一个大漏洞,支持 SMS 但不支持 MMS 是荒谬的。
You might be able to leverage the MMS application itself; there's code in there for sending the MMS. You can see the source at the Android source repository
您或许可以利用 MMS 应用程序本身;那里有发送彩信的代码。您可以在Android源代码库中查看源代码