SMS message

wantlin

Member
Licensed User
Longtime User
Hi
I have problem for SMS message function.
If I receive the SMS message , how do I show the message to variable .
Because I need to confirm the message contents.

Thank you ,:sign0089::sign0085:
 

Penko

Active Member
Licensed User
Longtime User
Take a look on Basic4android - Phone (SMSInterceptor).

Also, this topic gives you an idea of how to listen for incoming SMS messages:
http://www.b4x.com/forum/basic4android-updates-questions/21261-ask-help-smsinterceptor.html#post122812

It's best to use a service which listens for new incoming messages. But everything depends on what you want to achieve.

Basically, you will have something like this:

B4X:
 Sub sms_MessageReceived (From As String, Body As String) As Boolean
     ToastMessageShow("adr:"&From&" content:"&Body,True)
     If Body.IndexOf("SOME TEXT TO CHECK") <> -1 Then
             m.Initialize
             m.Address=From
             m.Body=Body
             Log(m)
              
             'eat the event
             ToastMessageShow("吃掉事件",True)
             Return True
     End If
     'not eat the event
     ToastMessageShow("不吃事件",True)
     Return False
 End Sub

Of course, you have to initialize the eventName as "sms".
 
Upvote 0
Top