Android SDK中MMS [英] Android SDK MMS

查看:141
本文介绍了Android SDK中MMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

有关发送MMS就像我们发送短信的Andr​​oid就是这么简单。
这里是code片段。

意向书我=新的意图(Intent.ACTION_SEND);
i.putExtra(地址,7404357000);
i.putExtra(sms_body,你好......);
i.putExtra(Intent.EXTRA_STREAM,URI);
i.setType(图像/ PNG);
startActivity(ⅰ);
在这里,URI是:

 开放的我们的uri = Uri.parse(内容://媒体/外部/图片/媒体/ 1);

开放的我们的uri = Uri.parse(文件://mnt/sdcard/test.jpg);

开放的我们的uri = Uri.parse(文件://+ Environment.getExternalStorageDirectory()+/test.jpg);

确保test.jpg放在在SD卡present或可用。
你还需要给在manifest文件的权限。

 <使用-权限的Andr​​oid:名称=android.permission.RECEIVE_MMS/>
<使用-权限的Andr​​oid:名称=android.permission.SEND_SMS/>
<使用-权限的Andr​​oid:名称=android.permission.RECEIVE_SMS/>
 

下面是仿真器的最终输出。
这code也做工精细设备

下面是链接

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.

解决方案

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

Here is the link

这篇关于Android SDK中MMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆