android-smsmms icon indicating copy to clipboard operation
android-smsmms copied to clipboard

Sending MMS is failing on Android 12 with target API as 31

Open NickM-27 opened this issue 3 years ago • 4 comments

I updated my app to Android 12 and on an Android 12 device sending MMS fails

NickM-27 avatar Aug 18 '21 21:08 NickM-27

@NickM-27 Does it work when you set the target API to 30?

ravibpatel avatar Aug 26 '21 06:08 ravibpatel

@ravibpatel i was able to fix it on my local build by overwriting the transaction class. It's due to MUTABLE not being specified in the pending intents flags

NickM-27 avatar Aug 26 '21 12:08 NickM-27

@ravibpatel i was able to fix it on my local build by overwriting the transaction class. It's due to MUTABLE not being specified in the pending intents flags

Could I know more detailed? In my case, sending MMS is failing on Android 11 with Google Pixel phone. No issue on Galaxy.

BareumSW avatar Sep 02 '21 12:09 BareumSW

@BareumSW You have to provide Mutability flag to all PendingIntent used in Transaction class as shown here.

Just change it and other PendingIntent you find in Transaction class as shown below.

Before

PendingIntent sentPI = PendingIntent.getBroadcast(
                        context, messageId, sentIntent, PendingIntent.FLAG_UPDATE_CURRENT);

After

PendingIntent sentPI = PendingIntent.getBroadcast(
                        context, messageId, sentIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);

It is required to provide mutability flag for PendingIntent if you are targeting Android 12 or above. It is mentioned in docs here. Prior to Android 12, a PendingIntent created without this flag was mutable by default.

ravibpatel avatar Sep 02 '21 12:09 ravibpatel