Hello to all,
my app receive an SMS, read it, execute some actions, delete it, and send an SMS for to answer.
This is all inside a service, and it works very well !!
But now, my customer has changed the device, and the new have OS 4.2.2
My app works, but can't delete SMS
I knowed this problem, and I know that I need to register my app as an intent for to receive SMS, but I don't understand it very well.
I need a "dynamic receivers" as Erel explain
here, but I am a newbie.
I thinked that when my service start, it register the intent, when the service stop, de-register it.
In my service, I have these routines:
Sub Service_Create
server.Initialize("Server")
server.Start(5555) ' is an http service
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo("SendSMS attivo", "", Main)
Service.StartForeground(1, n)
Timer1.Initialize("Timer1", 10000) ' 10 seconds
End Sub
Sub Timer1_Tick ' every 10 seconds.....
Timer1.Enabled=False
' read SMS
Dim smsmanager As SmsMessages
Dim Lst As List
Lst = smsmanager.GetAll()
Dim smsmsg As Sms
For idx = 0 To Lst.Size - 1
smsmsg = Lst.Get(idx)
If smsmsg.Address = "the right phone number" Then
' execute my action........
smsmanager.deletesms(smsmsg.Id) ' <<<<<< this line don't work
End If
Next
Timer1.Enabled=True
End Sub
Please, can you tell me how I can register my service as an android.provider.Telephony.SMS_RECEIVED ??
But then, when an SMS is received, I need to do also or not ??
Many thanks for your help
Sergio