B4A Library SMSplus libinclude delete sms

:icon_clap:
Toaday I had wrote a new llib extends the official phone lib,It has only add the delete function because I did not found this function is the official lib .
here is the code:
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim a As SmsMessages
   Dim Button1 As Button
   Dim Button2 As Button
   Dim EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("123")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub Button2_Click
   Dim id As String
   id=EditText1.Text
   If id=Null Then Return
   If a.deletesms(id) Then
   Log("删除短信成功(delete sms ok)")
      Else
   Log("删除短信失败(delete sms error)")
   End If
   
End Sub
Sub Button1_Click
   Dim list1 As List
list1=a.GetAll()
For i=0 To list1.Size-1
Log(list1.Get(i))
Next
End Sub
the lib and demo src are in the attach zip file!Enjoy it.
 

Attachments

  • smspluslib.zip
    11.2 KB · Views: 1,044

BaGRoS

Active Member
Licensed User
I use Your library, but after deleting last sms, sms is back. This happens after leaving thread and entrance to thread.

B4X:
Sub si_MessageReceived(From As String, Body As String) As Boolean
    
   'Log(From)
   'ToastMessageShow(From & " - " & Body,False)
   
   
    If Body.Contains("Wiadomosc odebrana od:") OR Body.Contains("Wiadomosc nadana do:") Then
   
      Dim Writer As TextWriter
      Writer.Initialize(File.OpenOutput(File.DirRootExternal, "TrescSMS.txt", True))
      Writer.WriteLine(Body)
      Writer.Close
      
      
      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
               
         Log(smsBody)
         If smsBody.Contains("Wiadomosc odebrana od:") OR smsBody.Contains("Wiadomosc nadana do:") Then
         
            Log("Kasuje")
             If SmsMessages1.deletesms(smsID) Then
                Log("(delete sms ok)")
                    Else
                Log("(delete sms error)")
             End If
            SmsMessages1.deletesms(smsID)
            
         End If

      Next
       'Log ("Odebrało się")
         
    End If
    
End Sub
 

handi trisakti

New Member
Licensed User
to: smsplus library

i was hopeful, but after passing the ID, it says deleted ok, but in messages, the SMS still there.
in prev postings (around 2012), I saw people were able to delete ..
So, is it android4.4 that does not allow the code in this library to delete ..??

thanx
 
Last edited:

Devv

Active Member
Licensed User
Very useful lib the problem is when using the library it blocks the stock sms.GetByMessageId
 
Top