AddPermission("android.permission.SEND_SMS") (in Manifest)
Dim Sms1 As PhoneSms
Sms1.Send(3105551212,"Android SMS test")
Log("SMS Sent")
Sms1.Send(3105551212,"Android SMS test")
Sms1.Send("3105551212","Android SMS test")
'I get the message on my phone but this event does not write to the log:
Sub MessageReceived (From As String, Body As String) As Boolean
Log("+++++++++++++++++SMS From:" & From)
Log("+++++++++++++++++SMS Body:" & Body)
End Sub
'I can send out an SMS message ok and now receive it but these two events do not write to the log:
Sub SmsSentStatus (Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent)
Log("+++++++++++++++++SmsSentStatus PhoneNumber:" & PhoneNumber)
Log("+++++++++++++++++SmsSentStatus SmsSentStatus:" & Success)
Log("+++++++++++++++++SmsSentStatus ErrorMessage:" & ErrorMessage)
Log("+++++++++++++++++SmsSentStatus Intent:" & Intent)
End Sub
Sub SmsDelivered (PhoneNumber As String, Intent As Intent)
Log("+++++++++++++++++SmsDelivered PhoneNumber:" & PhoneNumber)
End Sub
Dim Sms2Intercept As SmsInterceptor
Sms2Intercept.Initialize2 ("MessageReceived", 999)
Sub SI2_MessageReceived (From As String, Body As String) As Boolean
Sub MessageReceived (From As String, Body As String) As Boolean
Dim SI2 As SmsInterceptor
Sending a message is very simple: Basic4android - Phone
Intercepting messages is done with SmsInterceptor: Basic4android - Phone
You need to add a service to your project with this object.
Sending a message is very simple: Basic4android - Phone
Intercepting messages is done with SmsInterceptor: Basic4android - Phone
You need to add a service to your project with this object.
(I'm using HeyWire with a supplied free phone number) the app shows it but the SMS Interceptor does not 'see it' come in.
Hmmm...I'm trying to use the code below, but I never get the SMS test message on my phone. I have SMS enabled and send and receive SMS messages everyday on my phone, so I know it works.
I have tried this code in my Service module and in an Activity, but I never get the SMS message on my phone.
Am I missing some more needed code?
B4X:AddPermission("android.permission.SEND_SMS") (in Manifest) Dim Sms1 As PhoneSms Sms1.Send(3105551212,"Android SMS test") Log("SMS Sent")
(I use my own cell phone number in place of 3105551212)
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim si, sr As SmsInterceptor
Dim SMSs As PhoneSms
End Sub
...
Sub Service_Create
'PE.Initialize("PE")
'si outgoing messages
si.Initialize2("si",998)
si.ListenToOutgoingMessages
'incoming messages
sr.Initialize2("sr",999)
End Sub
...
Sub sr_MessageReceived (From As String, Body As String) As Boolean
Log(From)
If From.Contains("880166533") Then
Log ("Odebrało się")
'Code of delete the message
End If
End Sub
...
Sub si_MessageSent (MessageId As Int)
Dim sm As SmsMessages
Dim res As List = sm.GetByMessageId(MessageId)
If res.Size > 0 Then
Dim msg As Sms
msg = res.Get(0)
Log(msg)
....