Android Question send sms using google messages stopped working - urgent ...

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi

i'm using the bellow code to send sms

B4X:
Intent1.Initialize(Intent1.ACTION_VIEW, "sms:" & PhoneNumber)
Intent1.PutExtra("sms_body", TextMessage)
StartActivity(Intent1)

it worked perfectly until recently
now - with google updated sms app it does not work (the sms app opens but no message is attached to the message text box)

with any other app like samsung's it works perfectly

as i don't control the user's phone some uses googe sms app (with or without rcs) and some uses other apps so i need it to work with any app
also i must comply with google as the app is on google play store

the sms sending feature is critical so please...

thanks
 

JohnC

Expert
Licensed User
Longtime User
Question: Are you just seeing this issue, or have your users reported seeing this issue too?

Have you tried rebooting your phone?
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Question: Are you just seeing this issue, or have your users reported seeing this issue too?

Have you tried rebooting your phone?
i got it from users
phones were rebooted several times
if using any other sms app it all works fine
on google the sms app loads with the target phone number but no message
so the issue seems to be only with google sms app
crazy
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If you verify it is an issue with the new version of Google Messages, then you can see if other developers reported the issue, or you can post this bug yourself here:

 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
If you verify it is an issue with the new version of Google Messages, then you can see if other developers reported the issue, or you can post this bug yourself here:

well i'm not sure where exactly is the problem
that's why i attached the code i use so others, much more skilled than me, will check and determine if it is my issue or what
i'm not that expert so i wait for the real experts here to their view
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
You can try this:

In manifest:
B4X:
AddPermission(android.permission.SEND_SMS)

Then you need to ask permission
B4X:
    Dim rp As RuntimePermissions
    For Each per In Array(rp.PERMISSION_SEND_SMS)
        rp.CheckAndRequest(per)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        If Not (Result) Then
            Msgbox("No permission, no party","")
            Activity.Finish
            Return
        End If
    Next

And the sub for to send SMS:
B4X:
Sub SendLargeSms(Destination As String, Message As String)

    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    Dim parts As Object
    parts = r.RunMethod2("divideMessage", Message, "java.lang.String")
    r.RunMethod4("sendMultipartTextMessage", _
        Array As Object(Destination, Null, parts, Null, Null), _
        Array As String("java.lang.String", "java.lang.String", _
        "java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))

End Sub
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
You can try this:

In manifest:
B4X:
AddPermission(android.permission.SEND_SMS)

Then you need to ask permission
B4X:
    Dim rp As RuntimePermissions
    For Each per In Array(rp.PERMISSION_SEND_SMS)
        rp.CheckAndRequest(per)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        If Not (Result) Then
            Msgbox("No permission, no party","")
            Activity.Finish
            Return
        End If
    Next

And the sub for to send SMS:
B4X:
Sub SendLargeSms(Destination As String, Message As String)

    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    Dim parts As Object
    parts = r.RunMethod2("divideMessage", Message, "java.lang.String")
    r.RunMethod4("sendMultipartTextMessage", _
        Array As Object(Destination, Null, parts, Null, Null), _
        Array As String("java.lang.String", "java.lang.String", _
        "java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))

End Sub
Thanks
I know this routine
Google play store rejects it so it must be another way that google will allow it
The intent way is acceptable by google and works with other sms apps except google's
How odd...

So i need a way to send sms that google store accepts it...
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
(ChatGPT)

It seems that with the latest updates to Google's Messages app, handling the sms_body extra through Intent is no longer working as expected, potentially due to restrictions or changes related to RCS (Rich Communication Services).

To ensure compatibility with all SMS apps, including Google's, consider trying the following approach:

1. Use ACTION_SENDTO​

Google recommends using Intent.ACTION_SENDTO instead of Intent.ACTION_VIEW when dealing with SMS to ensure compatibility with all messaging apps, including Google's SMS app with RCS.

You can try this code:
B4X:
Dim Intent1 As Intent
Intent1.Initialize(Intent.ACTION_SENDTO, "smsto:" & PhoneNumber)
Intent1.PutExtra("sms_body", TextMessage)
StartActivity(Intent1)

2. Handle SMS Permissions​

If your app sends SMS or needs to prefill messages, make sure you request the necessary SMS permissions in your AndroidManifest.xml:
B4X:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />

3. Fallback if Pre-filling Fails​

Since Google's Messages app may ignore the sms_body extra, one workaround is to prefill the message manually via code (copy to clipboard or provide it for the user to paste). You can use the clipboard as a backup if the body does not prefill:
B4X:
Dim clip As Clipboard
clip.Initialize
clip.SetText(TextMessage)
ToastMessageShow("Message copied. Paste it into the SMS app.", False)

Dim Intent1 As Intent
Intent1.Initialize(Intent.ACTION_SENDTO, "smsto:" & PhoneNumber)
StartActivity(Intent1)

This way, users can manually paste the message if the app doesn’t automatically include it.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
(ChatGPT)

It seems that with the latest updates to Google's Messages app, handling the sms_body extra through Intent is no longer working as expected, potentially due to restrictions or changes related to RCS (Rich Communication Services).

To ensure compatibility with all SMS apps, including Google's, consider trying the following approach:

1. Use ACTION_SENDTO​

Google recommends using Intent.ACTION_SENDTO instead of Intent.ACTION_VIEW when dealing with SMS to ensure compatibility with all messaging apps, including Google's SMS app with RCS.

You can try this code:
B4X:
Dim Intent1 As Intent
Intent1.Initialize(Intent.ACTION_SENDTO, "smsto:" & PhoneNumber)
Intent1.PutExtra("sms_body", TextMessage)
StartActivity(Intent1)

2. Handle SMS Permissions​

If your app sends SMS or needs to prefill messages, make sure you request the necessary SMS permissions in your AndroidManifest.xml:
B4X:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />

3. Fallback if Pre-filling Fails​

Since Google's Messages app may ignore the sms_body extra, one workaround is to prefill the message manually via code (copy to clipboard or provide it for the user to paste). You can use the clipboard as a backup if the body does not prefill:
B4X:
Dim clip As Clipboard
clip.Initialize
clip.SetText(TextMessage)
ToastMessageShow("Message copied. Paste it into the SMS app.", False)

Dim Intent1 As Intent
Intent1.Initialize(Intent.ACTION_SENDTO, "smsto:" & PhoneNumber)
StartActivity(Intent1)

This way, users can manually paste the message if the app doesn’t automatically include it.
thanks

chat-gpt is a great tool but...

i get error on this:
Main - 16794: Unknown member: action_sendto

so do i go on from here?

EDIT:
tried action_send
this worked but very strange - it opens all sms apps BUR google's
there was no way to choose google
even when it is set as default

this is getting stranger even more now
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
thanks

chat-gpt is a great tool but...

i get error on this:
Main - 16794: Unknown member: action_sendto

so do i go on from here?
1728972216008.png
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
sorry
that doesn't work

Intent1.Initialize("Intent1.ACTION_SENDTO", "smsto:" & PhoneNumber)
generates a runtime error for activity not found sendto...

and
Intent1.Initialize(Intent1.ACTION_SEND, "smsto:" & PhoneNumber)
does not even show google sms app - it shows all other but google

i think that google since RCS changed their app class as direct message or else but not as simply sms so the sms picker doesn't see it

how come only i got this issue?
no one else sends sms anymore ?
 
Upvote 0
Top