Differentiate MMS and SMS via MMS/SMS listeners in

2019-04-28 17:11发布

问题:

Is there any ways to differentiate MMS and SMS messages by using a MMS/SMS listener before they hit the inbox?

回答1:

The first indicator of an MMS message is a WAP-push with the MIME-type "application/vnd.wap.mms-message", so you could register a receiver for "android.provider.Telephony.WAP_PUSH_RECEIVED":

    <receiver android:name=".SomeReceiverName"
        android:permission="android.permission.BROADCAST_WAP_PUSH">
        <intent-filter>
            <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
            <data android:mimeType="application/vnd.wap.mms-message" />
        </intent-filter>
    </receiver>

To discover whether or not its a received MMS you're going to have to crack open the PDU:s and extract the X-Mms-Message-Type, which should be m-notification-ind (as per WAP 209). You can also pick out the X-Mms-Transaction-ID, which one thinks should be stored in the Telephony.Mms.TRANSACTION_ID column in the message provider if you want to link them up later.



标签: android sms mms