Hi,
I can programmatically read the incoming SMS message and the sender's mobile number. It is working fine.
Here comes the problem, I have a dual SIM phone and the SMS can arrive on any of the 2 numbers. I want to interpret and understand on which number the SMS message arrived.
I am using the following code to intercept the incoming SMS. It is the same code provided in the post https://www.b4x.com/android/forum/t...cepting-sms-messages-in-the-background.20103/
From the above code, the Sub ParseSmsIntent() is used to identify the sender's number and the message body. I would like to know the number to which the SMS has arrived on a dual SIM phone.
Please help
I can programmatically read the incoming SMS message and the sender's mobile number. It is working fine.
Here comes the problem, I have a dual SIM phone and the SMS can arrive on any of the 2 numbers. I want to interpret and understand on which number the SMS message arrived.
I am using the following code to intercept the incoming SMS. It is the same code provided in the post https://www.b4x.com/android/forum/t...cepting-sms-messages-in-the-background.20103/
B4X:
'Service module
Sub Process_Globals
Type Message (Address As String, Body As String)
End Sub
Sub Service_Create
End Sub
Sub Service_Start(startingIntent As Intent)
If startingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
Dim messages() As Message
messages = ParseSmsIntent(startingIntent)
For i = 0 To messages.Length - 1
Log(messages(i))
Next
End If
Service.StopAutomaticForeground
End Sub
'Parses an SMS intent and returns an array of messages
Sub ParseSmsIntent (in As Intent) As Message()
Dim messages() As Message
If in.HasExtra("pdus") = False Then Return messages
Dim pdus() As Object
Dim r As Reflector
pdus = in.GetExtra("pdus")
If pdus.Length > 0 Then
Dim messages(pdus.Length) As Message
For i = 0 To pdus.Length - 1
r.Target = r.RunStaticMethod("android.telephony.SmsMessage", "createFromPdu", _
Array As Object(pdus(i)), Array As String("[B"))
messages(i).Body = r.RunMethod("getMessageBody")
messages(i).Address = r.RunMethod("getOriginatingAddress")
Next
End If
Return messages
End Sub
From the above code, the Sub ParseSmsIntent() is used to identify the sender's number and the message body. I would like to know the number to which the SMS has arrived on a dual SIM phone.
Please help