Android SDK 彩信

发布于 2024-08-14 23:02:46 字数 95 浏览 8 评论 0原文

有谁知道如何通过 Android SDK 以编程方式发送彩信?任何版本的 SDK 都可以,只需要知道从哪里开始。我知道如何发送/接收短信,现在我需要在发送之前在消息中添加图片。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

悸初 2024-08-21 23:02:46

这对我有用。

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"); 

传递给 Uri.parse 方法的 url 应该采用用于访问媒体存储的形式,例如 content://media/external/images/media/23。

来自 jtribe 的系列。

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.

From the series at jtribe.

晚雾 2024-08-21 23:02:46

在 Android 上发送彩信就像我们发送短信一样简单。
这是代码片段。

意图 i = 新意图(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");

确保 SD 卡中存在或可用“test.jpg”。
您还需要在 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" />

这是模拟器上的最终输出。
此代码在设备上也可以正常工作
在此处输入图像描述

这是 链接

For Sending an MMS is Android is as simple just like we send an SMS.
Here is the Code Snippet.

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");

Make sure that "test.jpg" is present or available in the SD Card.
You also need to give the permission in the Manifest file.

<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
enter image description here

Here is the link

若言繁花未落 2024-08-21 23:02:46

我很想亲自得到这个问题的答案。目前看来,API 中存在一个巨大的漏洞,并且支持 SMS 但不支持 MMS,这很荒谬。

您也许可以利用 MMS 应用程序本身;里面有发送彩信的代码。可以看到源码位于 Android 源代码存储库

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.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文