Android Question SMS without delivery reports

AlpVir

Well-Known Member
Licensed User
Longtime User
The following 3 snippets of code send an SMS but - alas - charging the recipient ALWAYS the cost of the so-called "SMS delivery reports"; in total 0.15 + 0.19 euros. This also if the recipient has a telephone plan that includes hundreds of free SMS. AND EVEN if the recipient has cleared the checkbox that appears in Messages - Menu - Settings - Text Messages (SMS) - SMS delivery reports (Request delivery report for each message you sent).

B4X:
Dim Sms1 As PhoneSms
Sms1.Send(numtel,txtSMS)

B4X:
Dim Sms1 As PhoneSms
Sms1.Send2(numtel,txtSMS,false,false)

B4X:
Sub SendSms(PhoneNumber As String, Text As String)
    Dim ps As PhoneSms
    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    r.RunMethod4("sendTextMessage", Array As Object(PhoneNumber, Null, Text, Null, Null), _
      Array As String("java.lang.String", "java.lang.String", "java.lang.String", _
         "android.app.PendingIntent", "android.app.PendingIntent"))
End Sub

Is there a way to prevent these unnecessary costs for the recipient of the SMS?
Thanks for the attention.
 

DonManfred

Expert
Licensed User
Longtime User
AND EVEN if the recipient has cleared the checkbox
The receipient is not relevant here i guess...
The Setting belongs to the device who is SENDING an SMS.

THIS device is requesting the report. This SMS is NOT part of the free SMS sending contingent i think.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
I did not understand.
Both the sender and the recipient have deactivated "SMS Delivery Reports".
The sender pays 2 SMS
The recipient receives the SMS free of charge.

If the sender had manually written the SMS would not pay anything.
With that code the sender pay 2 SMS
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
No. The message is about 100 characters.
If it was bigger I would have used the sub
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

The code
B4X:
Dim Sms1 As PhoneSms
Sms1.Send2(numtel,txtSMS, False,False)
is within a service.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Sent notifications and delivered notifications are not requested when calling PhoneSms.Send2 with both parameters set to False.
They are requested when you call PhoneSms.Send.

If you are sure that you are seeing a different behavior then test it with a different device.

The code is equivalent to:
B4X:
SmsManager.sendTextMessage(PhoneNumber, null, Text, null, null);
 
Upvote 0
Top