I am searching this for a while, I collected a few examples together. So far able to send large sms message.
I am trying to follow smssent and smsdelivered by a "message_id", which I added by intent.putExtra but
I got the final value for each message. Below message key is the referring ID of the message in DB server.
Intent.GetExtra("message_id") should return uniqie message id, but returns only the last one when there back to back multiple messages.
I think I tried check everything about this, but sure I am missing a parameter something. Need help?
I am trying to follow smssent and smsdelivered by a "message_id", which I added by intent.putExtra but
I got the final value for each message. Below message key is the referring ID of the message in DB server.
Send large sms function:
Sub SendLargeSms(Destination As String, Message As String, MessageKey As String)
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim smsManager As JavaObject
smsManager = smsManager.InitializeStatic("android.telephony.SmsManager").RunMethod("getDefault", Null)
Dim parts As JavaObject = smsManager.RunMethod("divideMessage", Array(Message))
Dim i As Intent
i.Initialize("b4a.smssent", "")
i.PutExtra("message_id", MessageKey)
Dim pi As JavaObject
pi = pi.InitializeStatic("android.app.PendingIntent").RunMethod("getBroadcast", _
Array(ctxt, 0, i, 134217728))
Dim i2 As Intent
i2.Initialize("b4a.smsdelivered", "")
i2.PutExtra("message_id", MessageKey)
Dim pi2 As JavaObject
pi2 = pi2.InitializeStatic("android.app.PendingIntent").RunMethod("getBroadcast", _
Array(ctxt, 0, i2, 134217728))
Dim size As Int = parts.RunMethod("size", Null)
Dim al, al2 As JavaObject
al.InitializeNewInstance("java.util.ArrayList", Null)
al2.InitializeNewInstance("java.util.ArrayList", Null)
For ii = 0 To size - 2
al.RunMethod("add", Array(Null))
al2.RunMethod("add", Array(Null))
Next
al.RunMethod("add", Array(pi))
al2.RunMethod("add", Array(pi2))
smsManager.RunMethod("sendMultipartTextMessage", Array(Destination, Null, parts, al, al2))
End Sub
Intent.GetExtra("message_id") should return uniqie message id, but returns only the last one when there back to back multiple messages.
I think I tried check everything about this, but sure I am missing a parameter something. Need help?
Intersect smssentevent:
Sub PE_SmsSentStatus (Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent)
Dim MsgId As String = Intent.GetExtra("message_id")
Do_SmsSentNotifyServer(MsgId)
Log ("SMSSentStatus:" & Success & ":" & ErrorMessage & ":" & MsgId)
Log(Intent.GetData)
End Sub
Last edited: