Android Question Block SMS based on keyword ?

Devv

Active Member
Licensed User
Longtime User
I'm trying to filter my ingoing sms
i want to make my app never show sms's that contain the word "car" anyware in the body of the sms
but it will allow all other sms's to show up normally

here is what i tried

B4X:
sub Process_Globals
    Dim soso As SmsInterceptor
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
soso.Initialize2("soso",0)
End Sub

Sub soso_MessageReceived(From As String,Body As String) As Boolean
Msgbox(Body,"MY APP" & From)
Return True
End Sub


this is intercepting all the ingoing sms when my app is foreground

how can i block or allow an sms based on a keyword in the body ?
 

Reviewnow

Active Member
Licensed User
Longtime User
B4X:
if body.contains("YOURKEYWORD") then

'do nothing

else
    Msgbox(Body,"My App" & from)
    Return True
End if
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
B4X:
if body.contains("YOURKEYWORD") then

'do nothing

else
    Msgbox(Body,"My App" & from)
    Return True
End if


thanks for replay
in my case will their be a difference between

B4X:
if body.contains("YOURKEYWORD") then
'do nothing

and


B4X:
if body.contains("YOURKEYWORD") then
return false

?
 
Upvote 0

Reviewnow

Active Member
Licensed User
Longtime User
You should return False did not see that you have a Boolean return value
 
Upvote 0
Top