【问题标题】:Android MMS Intent with with Image and body text带有图像和正文的 Android MMS Intent
【发布时间】:2013-05-03 19:15:21
【问题描述】:

我正在尝试创建一个 Intent,它将为我启动 MMS 应用程序,并附加一个图像文件和一些预定义的文本出现在消息正文中。

到目前为止,我已经能够完成其中一个或,但不能同时完成。

我尝试过的事情(及其结果):

sendIntent = new Intent(android.content.Intent.ACTION_SEND,Uri.parse("mms://"));
sendIntent.setType("image/gif");
sendIntent.putExtra(Intent.EXTRA_STREAM, imgStreamUri);
sendIntent.putExtra("sms_body", "HelloWorld");
startActivity(Intent.createChooser(sendIntent,"Send"));    
/**********
Image file is attached but no text added to message body.
 **********/

sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.setType("image/gif");
sendIntent.putExtra(Intent.EXTRA_STREAM, imgStreamUri);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "HelloWorld");
sendIntent.putExtra(Intent.EXTRA_TITLE, "WorldHello");
startActivity(Intent.createChooser(sendIntent,"Send"));
/**********
Image file is attached but no text added to message body(or subject or anything).
 **********/

有谁知道我如何将正文和图像文件附加到一个 mms 意图中,该意图将启动默认消息传递应用程序并填写适当的项目?

编辑: 测试了@lenik 在答案中提供的代码。它正在某些设备上运行,这是我发现的

正常工作:

  • 史诗4g(银河S)
  • Epic 4g Touch (Galaxy S II)
  • Galaxy Nexus(ICS 4.0.4)
  • HTC Desire (Froyo 2.2)
  • 摩托罗拉光子

附图但无文字:

  • Sidekick 4g
  • 三星 Transform Ultra

任何人都知道我是否基本上是 s.o.l.在不能以这种方式正常工作的设备上?

【问题讨论】:

    标签: android android-intent message mms


    【解决方案1】:

    以下代码适用于我:

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra("sms_body", "Hi how are you");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
    intent.setType("image/gif"); 
    startActivity(Intent.createChooser(intent,"Send"));
    

    【讨论】:

    • 我没有添加任何文字。你在什么设备上运行?
    • 适用于我的 HTC Desire (Froyo 2.2) 和 Galaxy Nexus (ICS 4.0.4)。
    • 请尝试使用我的sorce verbatim,很可能问题与您的imgStreamUri参数有关,如果内容错误,则文本或文件没有在彩信中正确显示。
    • 我刚刚能够在更广泛的设备上进行测试。查看我的编辑结果。
    • @lenik 如何以编程方式在 mms 中附加音频文件。
    猜你喜欢
    • 1970-01-01
    • 2011-03-14
    • 1970-01-01
    • 2015-12-01
    • 2012-09-03
    • 2011-10-11
    • 1970-01-01
    • 2018-02-19
    相关资源
    最近更新 更多