1

I created mms message. The problem is: that is showed in my app, but that does not show in android native message application. Do you have an idea what can be wrong? What should I set for the thread_id? Thanks in advance.

--- Here is my code ---

ContentResolver cr = getContentResolver();

ContentValues cv = new ContentValues(); 
cv.put("thread_id", System.currentTimeMillis() % 100); 
cv.put("ct_t", "application/vnd.wap.multipart.related");
cv.put("read", "1"); 
Uri temp_mms = cr.insert(Uri.parse("content://mms/inbox"), cv); 
String str_uri = temp_mms.toString(); 
String newID = temp_mms.getLastPathSegment().trim();

 ContentValues cv_addr2 = new ContentValues(); 
 cv_addr2.put("address", "112233"); 
 Uri temp_mms_addr2 = cr.insert(Uri.parse("content://mms/"+ newID +"/addr"), cv_addr2); 

 // ------------------------------PART Table ContentValues 
 Uri uriPart = Uri.parse("content://mms/"+ newID +"/part");
 ContentValues cv_part2 = new ContentValues(); 
 cv_part2.put("ct", "image/jpeg"); 
 Uri temp_mms_part2 = cr.insert(uriPart, cv_part2);

 OutputStream os = cr.openOutputStream(temp_mms_part2);
 InputStream is = cr.openInputStream(selectedImageUri);
 byte[] buffer = new byte[256];
 for (int len = 0; (len = is.read(buffer)) != -1; ) {
     os.write(buffer, 0, len);
 }
owner21
  • 11
  • 2

1 Answers1

1

Partial answer: not sure why it isn't showing up in the built-in messaging app, but check out the answer to How to Read MMS Data in Android? for how to get a thread id.

Edit: you also might need to add an address entry into content://mms/{id}/addr for the sender, and if this is coming from the current device, it seems like insert-address-token is enough. Address entries also need a type which should be set to 151 for receiving addresses and 137 for senders.

There's probably more that is needed, I would read the existing database and just go through it field by field and make sure you're covering things in there that aren't null or 0.

Community
  • 1
  • 1
gummihaf
  • 93
  • 1
  • 7