SMSIntercept still calls built in handler

jfitchett56

Member
Licensed User
Longtime User
Hello sirs. I am trying to implement smsintercept but given the example code it fires my event and handles the msg but the msg still displays in the sms list. According to docs, return true if w process it return false to let it bubble to the normal sms handler. code looks for msg to contain 'record' and should handle and block it if so...

'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
If messages(i).Body.Contains("record") Then
ToastMessageShow("hidden sms detected",True)
Return True
Else
Return False
End If
Next
End If
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
 

jfitchett56

Member
Licensed User
Longtime User
Don't understand

Thank you for the reply. I don't know how to use those tags, is it as simple as at start of code put
B4X:
 and at end put
? a tiny example of a reference would help and I will certainly comply.

I did get smsinterceptor to work as advertised. thank you.
 
Upvote 0
Top