I'm trying to create an app which will delete the sms received from specific name/number.
I'll use SMSpluslib to delete sms. Now I need your help.
My code is
B4X:
#
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim si As SmsInterceptor
Dim dl As SmsMessages
Dim Froms() As String
Forms = Array As String ("Offer", "Cricket")
End Sub
Sub Service_Create
si.Initialize2("si", 999)
End Sub
Sub Service_Start (StartingIntent As Intent)
StartService("")
End Sub
Sub Service_Destroy
StopService("")
End Sub
Sub si_MessageReceived (From As String, Body As String) As Boolean
If forms.Contains(From) Then
'Code of delete the message
End If
End Sub
Try the following solution:
- Use an intent filter to intercept messages in the background.
- If the message needs to be blocked then call another service with StartServiceAt 10 seconds from now.
- Use SMSplus library to get the latest SMS messages. Make sure that the phone number is correct and delete it.
Okay, I could able to get detail of a message, ex. id=1, threadid=5, ...... Address=Offer
I don't know how to get value of a specific parameter from the above string, ex. value of id or value Address in b4a.
I need your help in this point.
Okay, I could able to get detail of a message, ex. id=1, threadid=5, ...... Address=Offer
I don't know how to get value of a specific parameter from the above string, ex. value of id or value Address in b4a.
I need your help in this point.
Getting speciific value of id or threadid and for other is quite easy
You may use like this
B4X:
Dim SmsMessages1 As SmsMessages
Dim List1 As List
List1 = SmsMessages1.GetAllSince(DateTime.Add(DateTime.now, 0, 0, -1))
Dim smsID as String
Dim smsBody as String
Dim Sms1 As Sms
For i = 0 To List1.Size - 1
Sms1 = List1.Get(i)
smsBody= Sms1.Body 'Storing Specific Body
smsID= Sms1.ID 'Storing Specific ID
Next
Above one is only an example for you, Similarly you may use ThreadId, Read, Date/Time and more specific data of SMS