5

I spent 5 hours attempting to make a custom MMS Broadcast receiver work. I googled and searched here at Stackoverflow a gazillion of seemingly duplicate threads but non of the workarounds or proposed solutions.

A few random debugging notes:

  • The app is set as default SMS app and all permissions were granted.
  • Verified that RCS is disabled through Google's Messenger.
  • The DUT is a Pixel 3 XL with latest software updates.
  • Tested many 3P SMS/MMS apps, almost all aren't able to receive MMS either, however, Pulse does. Pulse's developer provides an Open Source MMS library. I tried leveraging this library without success. The core problem seems to be that WAP_PUSH_DELIVER Intents are not sent to my application.
  • Decoded the Pulse app to have a look at its AndroidManifest.xml and try a few different changes in mine. No success.
  • Test MMS were sent with Google Voice account via legacy Hangouts and from other Android phones via various carriers.
  • SMS can be received without problems both SMS_RECEIVED and SMS_DELIVER (if the app is the default SMS one).
  • WAP_PUSH_RECEIVED events are received if the app is not the default SMS one
  • WAP_PUSH_DELIVER events are not received if the app is the default SMS one
  • Installed Intent Intercepter and ran $ adb logcat | fgrep -i intent to verify if any permission problems are logged. None are.

MmsReceiver:

public class MmsReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        System.out.println("MMS Received: " + intent.getAction());
    }
}

Manifest:

<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.BROADCAST_WAP_PUSH" />
<uses-permission android:name="android.permission.BROADCAST_SMS" />
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.provider.Telephony.SMS_RECEIVED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SENDTO" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="sms" />
                <data android:scheme="smsto" />
                <data android:scheme="mms" />
                <data android:scheme="mmsto" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name=".SmsReceiver"
            android:permission="android.permission.BROADCAST_SMS">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_DELIVER" />
            </intent-filter>
        </receiver>

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

        <service
            android:name=".HeadlessSmsSendService"
            android:exported="true"
            android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE" >
            <intent-filter>
                <action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="sms" />
                <data android:scheme="smsto" />
                <data android:scheme="mms" />
                <data android:scheme="mmsto" />
            </intent-filter>
        </service>
    </application>

</manifest>

Needless to mention, the message is not logged in Logcat.

Basic Coder
  • 10,882
  • 6
  • 42
  • 75

1 Answers1

2

Make your app the default SMS app

On Android 4.4, only one app can receive the new SMS_DELIVER_ACTION intent, which the system broadcasts when a new SMS message arrives. Which app receives this broadcast is determined by which app the user has selected as the default SMS app in system settings. Likewise, only the default SMS app receives the new WAP_PUSH_DELIVER_ACTION intent when a new MMS arrives.

it looks your app isn't the default default SMS app. therefore, you are not permitted to listen for incoming broadcasts.

something you need is to navigate user to select your app as default.like as official doc says:

public class ComposeSmsActivity extends Activity {

    @Override
    protected void onResume() {
        super.onResume();

        final String myPackageName = getPackageName();
        if (!Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName)) {
            // App is not default.
            // Show the "not currently set as the default SMS app" interface
            View viewGroup = findViewById(R.id.not_default_app);
            viewGroup.setVisibility(View.VISIBLE);

            // Set up a button that allows the user to change the default SMS app
            Button button = (Button) findViewById(R.id.change_default_app);
            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Intent intent =
                            new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
                    intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, 
                            myPackageName);
                    startActivity(intent);
                }
            });
        } else {
            // App is the default.
            // Hide the "not currently set as the default SMS app" interface
            View viewGroup = findViewById(R.id.not_default_app);
            viewGroup.setVisibility(View.GONE);
        }
    }
}

And also, WAP_PUSH_DELIVER_ACTION highlights that

This intent will only be delivered to the default sms app

A Farmanbar
  • 4,381
  • 5
  • 24
  • 42
  • As I mentioned in my question, the app is set as default SMS app. This answer unfortunately doesn't help. – Basic Coder Jan 05 '20 at 19:08
  • @BasicCoder i mentioned "it looks your app isn't the default SMS app" it's not definitely target problem.but i think so. – A Farmanbar Jan 05 '20 at 21:00
  • Not sure what code you want to see considering that the app basically consists exclusively of a manifest and bunch of empty receivers... – Basic Coder Jan 06 '20 at 02:12
  • @BasicCoder "WAP_PUSH_RECEIVED events are received if the app is not the default SMS one" & "WAP_PUSH_DELIVER events are not received if the app is the default SMS one". can you explain these two more in your question ? and also what exactly you want. – A Farmanbar Jan 06 '20 at 02:29