Android Question PhoneSms and AndroidSdk version

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi to everybody
I have recently used an App using PhoneSms in Phone library,with no problem. Now I want to send Sms with another App and I get (at runtime):

java.lang.IllegalArgumentException: MyApp...:
Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE,
an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons.
To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.

The only difference that I see, between the two apps , is in the Manifest at:

AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)

As a matter of fact, the working App has 33 instead of 35 in targetSdkVersion.
Of course I also have, in Manifest:

AddPermission(android.permission.SEND_SMS)

And I ask for permission at runtime:
B4X:
   Dim rp as RuntimePermissions
   rp.CheckAndRequest(rp.PERMISSION_SEND_SMS)
   
    Wait For b4xPage_PermissionResult (Permission2 As String, Result2 As Boolean)
Before the crash which happens at :
B4X:
Dim MySms as PhoneSms

MySms.Send(Number,Text) ...and also in MySms.Send2

Changing 35 to 33 in the new App, makes it to work (despite I don't yet actually receive the sms, but It may be another problem)

Thanks in advance for any comment.
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Update: with TargetVersion 33 also the new App sends the Sms. Therefore the problem seems related to version 35.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Giovanni, shhhh, non ho voglia di impazzire ancora di più e non ho uno smartphone recente, per cui...
ho chiesto a ChatGPT. Condivido la chat, guarda se l'ultima versione che ha generato funzioni (ci credo moltissimo, circa allo 0,0000001% , ma prova, non si sa mai. Male che vada avrai qualche spunto).

-------

Giovanni, shhhh, I don't feel like going even crazier and I don't have a recent smartphone, so...

I asked ChatGPT. I'm sharing the chat, see if the latest version it generated works (I'm very confident in it, about 0.0000001% , but give it a try, you never know. Worst case scenario, you'll get some ideas).

**********

https://chatgpt.com/share/68d17447-8818-8002-bf0f-da70c4b9d4ca
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…