Hello everyone
To send sms I was using
But this works without problem with devices with Android 10
I am currently testing with a device with Android 14 and sms are not being sent.
Then I try to use the following:
But this error is shown in the log:
I appreciate the support if someone handled this error
To send sms I was using
B4X:
Sub SendMultipartTextMessage(Number As String, Message As String, SubscriptionId As Int) As ResumableSub
Dim r As Reflector
r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getSmsManagerForSubscriptionId", Array As Object(SubscriptionId), Array As String("java.lang.int"))
Dim parts As Object
parts = r.RunMethod2("divideMessage", Message, "java.lang.String")
r.RunMethod4("sendMultipartTextMessage", _
Array As Object(Number, Null, parts, Null, Null), _
Array As String("java.lang.String", "java.lang.String", _
"java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))
Return True
End Sub
But this works without problem with devices with Android 10
I am currently testing with a device with Android 14 and sms are not being sent.
Then I try to use the following:
B4X:
Sub SendLargeSms(Destination As String, Message As String)
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim smsManager As JavaObject
smsManager = smsManager.InitializeStatic("android.telephony.SmsManager").RunMethod("getDefault", Null)
Dim parts As JavaObject = smsManager.RunMethod("divideMessage", Array(Message))
Dim i As Intent
i.Initialize("b4a.smssent", "")
Dim pi As JavaObject
pi = pi.InitializeStatic("android.app.PendingIntent").RunMethod("getBroadcast", _
Array(ctxt, 0, i, 134217728))
Dim size As Int = parts.RunMethod("getSize", Null)
Dim al As JavaObject
al.InitializeNewInstance("java.util.ArrayList", Null)
For ii = 0 To size - 2
al.RunMethod("add", Array(Null))
Next
al.RunMethod("add", Array(pi))
smsManager.RunMethod("sendMultipartTextMessage", Array(Destination, Null, parts, al, Null))
End Sub
But this error is shown in the log:
B4X:
java.lang.IllegalArgumentException: com.sss.test: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkPendingIntent(PendingIntent.java:430)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:733)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:720)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at com.salinasystems.consultas.b4xcitas._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv6(b4xcitas.java:5442)
at com.salinasystems.consultas.b4xcitas$ResumableSub_etiRecordatorio_Click.resume(b4xcitas.java:3965)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:224)
at android.os.Looper.loop(Looper.java:318)
at android.app.ActivityThread.main(ActivityThread.java:8755)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
I appreciate the support if someone handled this error