Android Question Error sending an SMS despite having all permissions

AlpVir

Well-Known Member
Licensed User
Longtime User
To send an SMS the following code should be valid
B4X:
Dim Sms1 As PhoneSms
Sms1.Send(telnum,txtSMS)
or
B4X:
Dim Sms1 As PhoneSms
Sms1.Send2(telnum,txtSMS, False,False)
However I get the following error
java.lang.SecurityException: Sending SMS message: uid 10214 does not have android.permission.SEND_SMS.
despite having indicated in Manifest
AddPermission(android.permission.SEND_SMS)
and also having used the sub
B4X:
Sub CheckPermissions As ResumableSub
    For Each per In Array(rp.PERMISSION_READ_CONTACTS ,rp.PERMISSION_ACCESS_FINE_LOCATION, rp.PERMISSION_WRITE_EXTERNAL_STORAGE, rp.PERMISSION_SEND_SMS)
        rp.CheckAndRequest(per)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        If Result = False Then Return False
    Next
    Return True
End Sub
Where am I wrong ?
Thanks in advance
 

agraham

Expert
Licensed User
Longtime User
Forum search still works!
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
I had certainly read what was described in Erel's post, but, being this post from 2018, I believed that a remedy for this limitation had been found in the meantime.
So, if I understand correctly, there is no other way to send an SMS from B4A than using an intent.
Nor is there probably the possibility to check immediately whether the SMS has been sent or not.
When sending emails with the SMTPExtras library vice versa you can use the sub Sub SMTPExtras1_MessageSent2(Success As Boolean, Tag As Object) and check if the sending was successful. Very comfortable and effective.
That of Google is therefore, in my opinion, a great limitation.
 
Upvote 0
Top