【问题标题】:Android MIME type for MMS (SMS) messages?彩信(SMS)消息的Android MIME类型?
【发布时间】:2011-05-26 19:55:02
【问题描述】:

How to open Email program via Intents (but only an Email program) 的答案显示了如何通过调用 intent.setType("message/rfc822") 打开仅显示电子邮件程序的选择器。

我想做同样的事情,但选择支持彩信(甚至只是短信)而不是电子邮件程序。

最终目标是创建一个“分享对象”选择器,根据消息将采用的形式发送不同的内容。 (因为电子邮件可能比文本或推文长很多,并且可以包含视频附件。)

【问题讨论】:

标签: android android-intent send


【解决方案1】:

我相信这是 MMS 消息的 MIME 类型:“application/vnd.wap.mms-message” 这是 SMS 消息的 MIME 类型:“vnd.android-dir/mms-sm”

例子:

Manifest.xml 文件:

   <receiver android:name=".SMSReceiver"> 
        <intent-filter> 
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            <data android:mimeType="vnd.android-dir/mms-sms" />             
        </intent-filter> 
    </receiver>
    <service android:name=".SMSReceiverService"/>
   <receiver android:name=".MMSReceiver"> 
        <intent-filter>
            <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
            <data android:mimeType="application/vnd.wap.mms-message" />
        </intent-filter>
    </receiver>

这是迄今为止我在 Android 开发中使用 MIME 类型的方式。

【讨论】:

  • 向 SMSReceiver 添加数据 mimeType 似乎不起作用。我已将其关闭,我的 SMSReceiver 工作正常。
  • 另外我认为您正在寻找的 MIME 类型是 vnd.android-dir/mms-sms(注意结尾 s
【解决方案2】:

我发现了这个link to jTribe's blog。似乎有一个如何实现这一点的有效示例,但坦率地说,我找不到任何证明这是正确的文档。它做了一些奇怪的事情,比如将操作设置为 ACTION_VIEW(而不是 ACTION_SEND),然后使用字符串参数,而不是 Intent 类中的静态变量......但这里是代码:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "The SMS text"); 
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-28
    • 1970-01-01
    • 2016-06-26
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    • 2011-03-16
    • 1970-01-01
    相关资源
    最近更新 更多