Receiving MMS as the default SMS app
androidmmspduwap-pushsmstelephony
Incoming MMS on Android is a two-step dance: a WAP push SMS announces the message (M-Notification.ind), the app calls SmsManager.downloadMultimediaMessage(), and the system fetches the M-Retrieve.conf from the carrier's MMSC. The critical, poorly documented fact: when your app is the default SMS app, the system does not write the downloaded MMS into content://mms. Persisting it is your job.
The root cause that took four releases
AOSP's DownloadRequest.persistIfRequired() deliberately skips persistence when the requester is the default SMS handler. The system only writes the raw M-Retrieve.conf bytes into the file you passed to downloadMultimediaMessage(). An app that waits for a row to appear in content://mms waits forever, while the photo sits unread in its cache directory.
Three earlier "fixes" failed because they were never verified on the phone: the app was not even installed there, and another app (Textra) held the SMS role and was doing the persisting, which created the very symptoms being "fixed".
The working receive path
MmsReceivergets the WAP push, parses the notification, callsdownloadMultimediaMessage()with a UUID-named file, a unique data URI on the PendingIntent, and an explicit component (setClass).MmsDownloadedReceiverreads the PDU file:PduParser(bytes, true).parse()thenPduPersister.getPduPersister(ctx).persist(pdu, Telephony.Mms.Inbox.CONTENT_URI, true, true, null, subId).- Mirror into the app database, deduplicating by Message-ID.
- Send the M-NotifyResp.ind acknowledgement to the MMSC, or the carrier may push the same message again.
- Notify.
Verified end to end: WAP push to notification in under a second, provider row with m_type=132, msg_box=1.
Gotchas
- The NotifyResp transaction ID must round-trip as raw bytes. Re-encoding it through
String(US_ASCII)turns bytes at or above 0x80 into?; the MMSC matches by exact bytes and silently ignores the ACK. - Vendor the receive-side pdu_alt classes (PduParser, PduPersister, RetrieveConf). Strip DRM from PduPersister: it references the hidden
android.provider.DownloadsAPI. - Keep a real captured M-Retrieve.conf as a unit-test fixture (the Message app uses a 271,131-byte AT&T capture) so parser changes are tested against reality.
- The
MmsDownloadedReceiverbroadcast runs on the background queue (60 s budget, not 10 s), sogoAsync()work there is less tight than it looks. - Samsung and older devices store MMS text in a
_datafile rather than the inlinetextcolumn. - Some OEMs (ZTE) return nothing for a global
content://mms/addrquery; query addresses per message. - Delayed-download MMS keep their original
DATEheader, so any sync cursor for MMS must be the provider_ID, never the date (see Syncing an SMS app with the Android telephony provider).