在 android 上解析应用程序/smil MMS MIME 类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11556633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:02:16  来源:igfitidea点击:

Parse application/smil MMS MIME type on android

androidsmsmime-typesmms

提问by toobsco42

So I have come across three categories of MMS message types:

所以我遇到了三类彩信类型:

Plain Text - "text/plain"

Plain Text - "text/plain"

Image - "image/jpeg", "image/bmp", "image/gif", "image/jpg", "image/png"

Image - "image/jpeg", "image/bmp", "image/gif", "image/jpg", "image/png"

SMIL (Synchronized Multimedia Integration Language) - "application/smil"

SMIL (Synchronized Multimedia Integration Language) - "application/smil"

So I don't have an issue grabbing the data in an MMS that falls into the first two categories. However I am having trouble grabbing the data from MMS of message type application/smil

所以我在获取属于前两类的 MMS 中的数据时没有问题。但是我无法从消息类型的 MMS 中获取数据 application/smil

Below I have included 5 different examples of application/smilMMS messages that I have pulled from my phone.

下面我列出application/smil了我从手机中提取的5 个不同的彩信示例。

[31, 22, -1, application/smil, 123_1.smil, 106, null, null, <0000>, 0.smil, null, null, null, <smil>
  <head>
    <layout>
      <root-layout height="160" width="240"/>
      <region fit="meet" height="67%" id="Image" left="0%" top="0%" width="100%"/>
      <region fit="meet" height="33%" id="Text" left="0%" top="67%" width="100%"/>
    </layout>
  </head>
  <body>
    <par dur="8000ms">
      <img region="Image" src="cid:992"/>
    </par>
    <par dur="8000ms">
      <img region="Image" src="cid:993"/>
    </par>
  </body>
</smil>]

.

.

[22, 14, -1, application/smil, null, null, null, null, <smil>, smil.xml, null, null, null, <smil>
  <head>
    <layout>
      <root-layout width="320px" height="480px"/>
      <region id="Image" left="0" top="0" width="320px" height="320px" fit="meet"/>
      <region id="Text" left="0" top="320" width="320px" height="160px" fit="meet"/>
    </layout>
  </head>
  <body>
    <par dur="5000ms">
      <img src="8555" region="Image"/>
      <text src="text_0.txt" region="Text"/>
    </par>
  </body>
</smil>]

.

.

[13, 11, -1, application/smil, 123_1.smil, null, null, null, <0000>, null, null, null, null, <smil> 
  <head> 
    <layout> 
      <root-layout/>  
      <region fit="scroll" height="30%" id="Text" left="0%" top="70%" width="100%"/>  
      <region fit="meet" height="70%" id="Image" left="0%" top="0%" width="100%"/> 
    </layout> 
  </head>  
  <body> 
    <par dur="10000ms"> 
      <text region="Text" src="cid:928"/> 
    </par> 
  </body> 
</smil>]

.

.

[16, 13, -1, application/smil, mms.smil, null, null, null, <AAAA>, AAAA, null, null, null, <smil>
    <head>
        <layout>
            <root-layout width="240" height="160"/>
            <region id="Image" width="100%" height="67%" left="0%" top="0%" fit="meet"/>
            <region id="Text" width="100%" height="33%" left="0%" top="67%" fit="meet"/>
        </layout>
    </head>
    <body>
    <par dur="8000ms"><text src="text__01.txt" region="Text"/></par></body>
</smil>]

.

.

[5, 5, -1, application/smil, smil.smil, 106, null, null, <0000>, smil, null, null, null, <smil>
  <head>
    <layout>
      <root-layout height="160" width="240"/>
      <region fit="meet" height="67%" id="Image" left="0%" top="0%" width="100%"/>
      <region fit="meet" height="33%" id="Text" left="0%" top="67%" width="100%"/>
    </layout>
  </head>
  <body>
    <par dur="8000ms">
      <img region="Image" src="cid:351"/>
      <text region="Text" src="cid:352"/>
    </par>
  </body>
</smil>]

How exactly do you go about parsing this type of MMS? How do other texting apps deal with different kinds of MMS's? Any help would be greatly appreciated.

你究竟是如何解析这种类型的彩信的?其他短信应用程序如何处理不同类型的彩信?任何帮助将不胜感激。

回答by toobsco42

So the issue was that I was creating a Cursorlike this

所以问题是我正在创建一个Cursor这样的

Uri uri = Uri.parse("content://mms/part");
String[] projection = new String[] { "*" };
String selection = "_id = " + messageId;
Cursor cursor = mContentResolver.query(uri, projection, selection,null, null);

The problem is the selection arg should really be

问题是选择 arg 真的应该是

String selection = "mid = " + messageId;

Now my cursor contains multiple entries:

现在我的光标包含多个条目:

  1. One entry will correspond to the SMIL file. SMIL is a file format containing xml that helps an MMS viewer to know how to display the MMS. The MIME type for this entry is application/smil if you look at the column called ct (acronym for content type)

  2. Another entry will correspond to the text file that contains any text within that MMS besides the attachment. The MIME type of this will be text/plain

  3. Lastly, you will find another entry that actually has the attachment. This attachment can have a variety of different MIME types depending on what the file is. If it happens to be a jpeg it will be image/jpeg, if png it will be image/png etc...

  1. 一个条目将对应于 SMIL 文件。SMIL 是一种包含 xml 的文件格式,可帮助 MMS 查看者了解如何显示 MMS。如果您查看名为 ct(内容类型的首字母缩写词)的列,则此条目的 MIME 类型为 application/smil

  2. 另一个条目将对应于包含该 MMS 中除附件之外的任何文本的文本文件。此 MIME 类型将是 text/plain

  3. 最后,您会发现另一个实际包含附件的条目。这个附件可以有多种不同的 MIME 类型,这取决于文件是什么。如果它恰好是 jpeg,它将是 image/jpeg,如果它是 png,它将是 image/png 等...

I want to thank @wnafee for pointing this out in this post Android: what to do with application/smil MIME type.

我要感谢 @wnafee 在这篇文章中指出这一点Android: what to do with application/smil MIME type

回答by Den

You can start hereIt's android MMS viewer. Support SMIL. I use this code for my current project SMIL player for android.

你可以从这里开始 它是安卓彩信查看器。支持SMIL。我将此代码用于我当前的 android 项目 SMIL 播放器。

回答by Shaun

w3 has a nice library for working with SMIL. Check it out here http://www.w3.org/TR/1999/WD-smil-boston-dom-19991115/java-binding.html

w3 有一个很好的库用于处理 SMIL。在这里查看http://www.w3.org/TR/1999/WD-smil-boston-dom-19991115/java-binding.html