[Wish] Handle 2 intents of send sms method

brelto85

Active Member
Licensed User
Longtime User
Would be useful to add to the Send method (PhoneSMS library) 2 named parameters (ex: AllowDeliveryEvent and AllowSentEvent) to handle the 2 intents

B4X:
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);
        }
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Do you want to send SMS without these notifications? If yes then you can use this code:
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
 
Top