Android Question Expedition date/time of the received SMS

Maciej

Member
Licensed User
Longtime User
Hello,

Is it possible to get the expedition date/time of the received SMS ? Sms.Date gives the reception date/time of the received SMS.

BR,
Maciej
 

DonManfred

Expert
Licensed User
Longtime User
What is the expedition Date/Time??
 
Upvote 0

Maciej

Member
Licensed User
Longtime User
This is wrong.
On my « Nexus5 » or « Acer Liquid Z130” I can open the details of the received SMS to show the receive time AND sent time.

BR,
Maciej
 
Upvote 0

Maciej

Member
Licensed User
Longtime User
According to 3GGP specification 23.040 :

3.2.2 Service-Centre-Time-Stamp
The Service-Centre-Time-Stamp is the information element by which the SC informs the recipient MS about the time of
arrival of the short message at the SM-TL entity of the SC. The time value is included in every SMS-DELIVER
(TP-Service-Centre-Time-Stamp field, see clause 9) being delivered to the MS.

BR,
Maciej
 
Upvote 0

giacomo-italy

Member
Licensed User
Longtime User
Hi Erel,
i have modified the code of sms static receivers to receive sms time as follow:

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

I want to know, to get the date and time of sms, if it is correct the above code,
and if it is correct use the following code to get date and time in string format:

B4X:
data=DateTime.Date(messages(i).Time)
ora=DateTime.Time(messages(i).Time)

Thanks a lot
 
Upvote 0
Top