Search code examples
androidsmsmmsattachment

Programmatically add an mms to the inbox


using 1.5, i want to programmatically create an mms and insert it into inbox.

working code for inserting sms is

ContentValues val = new ContentValues();
val.put("body", "This is test message!!");
val.put("address", "1234");
val.put("date", "1234567891204");
getContentResolver().insert(Uri.parse("content://sms/inbox"), val);

this code is working, i need same thing (if possible) for inserting mms (i.e. text message with e.g. .png attachment) or may be close to this code.

any help?


Solution

  • well i figured out a way myself. AFAIK, you cannot insert message with attachments (programmatically) in conversations. A new messaging thread is not created for a message with attachments (don't know why). So you can insert a dummy sms for the recipient, then insert your message with attachments and delete the dummy sms. Hope it will help someone!