MM7 API (4)

来源:互联网 发布:nba季后赛数据排行榜 编辑:程序博客网 时间:2024/05/19 13:27
上篇提到下行彩信到MMSC,其中消息体还为提及,
MMContent content = new MMContent();    // 继承该类
/**设置附件的类型,若不包含SMIL格式的文件,则设置类型为MMConstants.ContentType. MULTIPART_MIXED,若包含SMIL格式的文件,则设置类型为MMConstants.ContentType. MULTIPART_RELATED*/
content.setContentType(MMConstants.ContentType. MULTIPART_MIXED);
/**添加类型为Gif的附件一 */
MMContent sub1 = MMContent.createFromFile("f://yellow.gif");
sub1.setContentID("1.gif");   //可以不设
/**设置子附件的类型,有两种设置方式:一种是在setContentType里面填写MMConstants.ContentType里面定义的常量,另一种是在setContentType里面填写一个String的类型,如text/plain等。*/
sub1.setContentType(MMConstants.ContentType.GIF); //一定要设置
content.addSubContent(sub1);
/**添加类型为Txt的附件二*/
MMContent sub2 = MMContent.createFromString("This is a Test2!");
sub2.setContentType(MMConstants.ContentType. TEXT); //一定要设置
sub2.setContentID("2.txt");
content.addSubContent(sub2);
/**将附件进行设置,设需发送消息为MM7SubmitReq*/
submitReq.setContent(content);  

原创粉丝点击