Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type SMSType (Msgid As Int,Msgdt As String,MsgFrom As String,MsgBody As String)
Public SMSList As List
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 cr As ContentResolver '------
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
SMSList.Initialize
End If
Activity.LoadLayout("Layout1")
cr.Initialize("cr")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim sms1 As List
sms1.Initialize
sms1 = GetSMS("AZ-AIRINF")
' Log(sms1.Size)
For i = 0 To sms1.Size -1
Dim ms As SMSType
ms = sms1.Get(i)
Log(ms.Msgid)
Log(ms.Msgdt)
Log(ms.MsgBody)
Next
End Sub
Sub GetSMS(SMSstr As String) As List
SMSList.Clear
Dim ur As Uri
ur.Parse("content://sms")
' Dim crsr As Cursor = cr.Query(ur, Null, "", Null, "") '' To read all fields in sms without any filter
Dim crsr As Cursor = cr.Query(ur,Array As String("_id","date","address","body"),"address = ?", Array As String(SMSstr),"_id")
Log("Number of columns = " & crsr.ColumnCount)
Log("Number of SMS = " & crsr.RowCount)
crsr.Position = 0
For r = 0 To crsr.RowCount -1
crsr.Position = r
Dim sms1 As SMSType
sms1.Initialize
sms1.Msgid = crsr.GetInt("_id")
sms1.MsgDt = crsr.GetLong("date")
sms1.MsgFrom = crsr.GetString("address")
sms1.MsgBody = crsr.GetString("body")
SMSList.Add(sms1)
Next
crsr.Close
Return SMSList
End Sub