【问题标题】:sending a picture as an MMS将图片作为彩信发送
【发布时间】:2012-07-01 22:42:12
【问题描述】:

我正在研究如何从我的应用程序在 android 中发送彩信。

我将名为 image1.png 的图像复制到文件资源管理器的 sdcard 文件夹中。它位于 mnt--> sdcard--> image1.png

我运行模拟器并扫描媒体,我可以在图库中找到图片。

现在发送彩信我使用以下代码

.................................................. .....................................

    Intent pic = new Intent(Intent.ACTION_SEND);
    pic.putExtra("sms_body", "click the above image");
    String url = "\\sdcard\\image1.png";
    pic.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
    pic.setType("image/png");
    startActivity(pic);

.................................................. .....................................

带有 sdcard 的模拟器已经在运行,现在当我运行应用程序时,它会打开带有 TO 字段的 mms 应用程序以及提到的 sms 正文,但图像未附加。我在我的上收到以下 toast 消息屏幕

.................................................. .....................................

“抱歉,您无法将此图片添加到您的消息中”

.................................................. .....................................

谁能帮我解决这个问题?

我不明白 uri 的概念。谁能帮帮我。

非常感谢

【问题讨论】:

标签: android image mms


【解决方案1】:

把你的代码改成

Intent pic = new Intent(Intent.ACTION_SEND);
pic.putExtra("sms_body", "click the above image");

String external = Environment.getExternalStorageDirectory().toString();
String path = "file://" + external + "/image1.png";

pic.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
pic.setType("image/png");
startActivity(pic);

所以实际上你需要预先附加“file://”

【讨论】:

    猜你喜欢
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    • 2015-04-09
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多