Successfully Sent MMS with multiple images :
Followed these steps to Sent MMS and also to add image in andorid database.
Problem: is i have 3 image in 1 mms and dont know how save them all against single MMS in android database.
I have tried this to save multiple images in single MMS by modifying method in given reference.
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;
}
This Method will save single image. it save image 1 and then override the new image bytes to pervious image.
how to save multiple images in single MMS.
Update Found solution:
To save mutiple image in single mms in android database. i just have to modify above like this.
Logic: we have to create multiple parts for single 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;
}