首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >发送带有多张图像的MMS android

发送带有多张图像的MMS android
EN

Stack Overflow用户
提问于 2016-01-06 08:39:05
回答 2查看 745关注 0票数 0

成功地发送了多个图像的彩信:

Followed these steps发送彩信,并在安道尔数据库中添加图像。

问题:是我在1 mms中有3张图片,并且不知道如何将它们全部保存到安卓数据库中的单个MMS中。

在给定的参考文献中,我尝试通过修改方法将多幅图像保存在单个MMS中。

代码语言:javascript
运行
复制
private static Uri createPart(Context context, String id,
            ArrayList<SentMMSVo> sentMMS2) throws Exception {
        ContentValues mmsPartValue = new ContentValues();
        mmsPartValue.put("mid", id);
        mmsPartValue.put("ct", "image/png");
        mmsPartValue.put("cid", "<" + System.currentTimeMillis() + ">");
        Uri partUri = Uri.parse("content://mms/" + id + "/part");
        Uri res = context.getContentResolver().insert(partUri, mmsPartValue);
        Log.e(">>>>>>>", "Part uri is " + res.toString());

        for (int i = 0; i < sentMMS2.size(); i++) {
            // Add data to part
            OutputStream os = context.getContentResolver()
                    .openOutputStream(res);
            ByteArrayInputStream is = new ByteArrayInputStream(sentMMS2.get(i)
                    .getData());
            byte[] buffer = new byte[256];
            for (int len = 0; (len = is.read(buffer)) != -1;) {
                os.write(buffer, 0, len);
            }
            os.close();
            is.close();
        }
        return res;
    }

此方法将保存单个图像。它保存图像1,然后将新的图像字节重写为透视图图像。

如何在单个MMS中保存多个图像。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-06 10:19:28

更新找到的解决方案:

将多个图像保存在android数据库中的单个mms中。我只需要像这样修改上面的内容。

逻辑:,我们必须为单个彩信创建多个部件。

代码语言:javascript
运行
复制
    private static Uri createPart(Context context, String id,
                ArrayList<SentMMSVo> sentMMS2) throws Exception {
            ContentValues mmsPartValue = new ContentValues();
            mmsPartValue.put("mid", id);
            mmsPartValue.put("ct", "image/png");


            for (int i = 0; i < sentMMS2.size(); i++) {
                // Add data to part
            mmsPartValue.put("cid", "<" + System.currentTimeMillis() + ">");
            Uri partUri = Uri.parse("content://mms/" + id + "/part");
            Uri res = context.getContentResolver().insert(partUri ,mmsPartValue);
            Log.e(">>>>>>>", "Part uri is " + res.toString());
                OutputStream os = context.getContentResolver()
                        .openOutputStream(res);
                ByteArrayInputStream is = new ByteArrayInputStream(sentMMS2.get(i)
                        .getData());
                byte[] buffer = new byte[256];
                for (int len = 0; (len = is.read(buffer)) != -1;) {
                    os.write(buffer, 0, len);
                }
                os.close();
                is.close();
            }
            return res;
        }
票数 0
EN

Stack Overflow用户

发布于 2016-01-06 08:41:52

这可能会帮助您,本教程演示如何从SD卡发送多个图像。

https://www.youtube.com/watch?v=55hRGBJ1-2E

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34628740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档