SendSms delivery and sent intents


Active Member
Licensed User
I found in the forum this method that prevent the delivery notice after sending sms (which involved an additional cost)

I would ask if using this method, the event "SmsSent" works or if need to implement the corresponding PendingIntent (sentIntent)

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", _
            "", ""))
End Sub



B4X founder
Staff member
Licensed User
It will be easier to implement it with a small library. This is PhoneSms code:
public static void Send(String PhoneNumber, String Text) {
         SmsManager sm = SmsManager.getDefault();
         Intent i1 = new Intent("b4a.smssent");
         i1.putExtra("phone", PhoneNumber);
         PendingIntent pi = PendingIntent.getBroadcast(BA.applicationContext, 0,i1, PendingIntent.FLAG_UPDATE_CURRENT);
         Intent i2 = new Intent("b4a.smsdelivered");
         i2.putExtra("phone", PhoneNumber);
         PendingIntent pi2 = PendingIntent.getBroadcast(BA.applicationContext, 0,i2, PendingIntent.FLAG_UPDATE_CURRENT);
         sm.sendTextMessage(PhoneNumber, null, Text, pi, pi2);
You should remove pi2.
Upvote 0


Active Member
Licensed User
Easy though i have no experience with the creation of a library.

Would be better if you update the Phone library, adding of those 2 parameters (eg AllowDeliveryEvent, AllowSentEvent)
Upvote 0