成功地发送了多个图像的彩信:
Followed these steps发送彩信,并在安道尔数据库中添加图像。
问题:是我在1 mms中有3张图片,并且不知道如何将它们全部保存到安卓数据库中的单个MMS中。
在给定的参考文献中,我尝试通过修改方法将多幅图像保存在单个MMS中。
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中保存多个图像。
发布于 2016-01-06 10:19:28
更新找到的解决方案:
将多个图像保存在android数据库中的单个mms中。我只需要像这样修改上面的内容。
逻辑:,我们必须为单个彩信创建多个部件。
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;
}发布于 2016-01-06 08:41:52
这可能会帮助您,本教程演示如何从SD卡发送多个图像。
https://stackoverflow.com/questions/34628740
复制相似问题