Android Question Getting the Date and Time of SMS

JhoeyBoy

Member
Licensed User
Longtime User
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Type Message (Address As String, Body As String, Time as Long)' -------i added here Time as Long
End Sub

Sub Service_Start (StartingIntent As Intent)
If StartingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
      Dim messages() As Message
      messages = ParseSmsIntent(StartingIntent)
      For i = 0 To messages.Length - 1
        Log(messages(i))
      Next
   End If
End Sub

'Parses an SMS intent and returns an array of messages
Sub ParseSmsIntent (In As Intent) As Message()
   Dim messages() As Message
   If In.HasExtra("pdus") = False Then Return messages
   Dim pdus() As Object
   Dim r As Reflector
   pdus = In.GetExtra("pdus")
   If pdus.Length > 0 Then
      Dim messages(pdus.Length) As Message
      For i = 0 To pdus.Length - 1
         r.Target = r.RunStaticMethod("android.telephony.SmsMessage", "createFromPdu", _
            Array As Object(pdus(i)), Array As String("[B"))
         messages(i).Body = r.RunMethod("getMessageBody")
         messages(i).Address = r.RunMethod("getOriginatingAddress")
         messages(i).Time = r.RunMethod("getTimestampMillis")'------- i added here your code
      Next
   End If
   Return messages
End Sub


this error occurred..
can't get the value of time

thanks a lot...


 

JhoeyBoy

Member
Licensed User
Longtime User
My apologies for this post.. Please remove it for not complicating the same topic..

Issues solve..


Thanks...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…