Hi all,
I have a problem with an app.
This is a simple app where accelerometer, orientation and GPS location must register information into CSV file. I want this process be executed in background as a service and the registration frequency must be each 2 seconds.
The problem is that information is registered with diferente periods (some times 5 seconds, anothter times 10 seconds).
How can i get a service execution each 2 seconds?
This is an extract for the app developed:
- Servicio (service):
- Main (Activity):
This is enought information? Is this a correct implementation for 2 second service loop?
Thanks in advance.
Regards
I have a problem with an app.
This is a simple app where accelerometer, orientation and GPS location must register information into CSV file. I want this process be executed in background as a service and the registration frequency must be each 2 seconds.
The problem is that information is registered with diferente periods (some times 5 seconds, anothter times 10 seconds).
How can i get a service execution each 2 seconds?
This is an extract for the app developed:
Sub Service_Start (StartingIntent As Intent)
StartServiceAt("", DateTime.Now + 2 * DateTime.TicksPerSecond, True)
CallSubDelayed(Main, "registro_file")
End Sub
StartServiceAt("", DateTime.Now + 2 * DateTime.TicksPerSecond, True)
CallSubDelayed(Main, "registro_file")
End Sub
Sub registro_file
DateTime.DateFormat = "ddMMyyyy"
date = DateTime.Date(DateTime.now)
hour = DateTime.GetHour(DateTime.Now)
minute = DateTime.GetMinute(DateTime.Now)
second = DateTime.GetSecond(DateTime.Now)
line_csv = date & "," & hour & ":" & minute & ":" & second & "," & Label3.Text & "," & _
Label4.text & "," & lbl_acele & "," & lbl_orien & "," & lblLat.Text & "," & lblLon.Text & "," & lblSpeed.Text & CRLF
List1.Add(line_csv)
End Sub
DateTime.DateFormat = "ddMMyyyy"
date = DateTime.Date(DateTime.now)
hour = DateTime.GetHour(DateTime.Now)
minute = DateTime.GetMinute(DateTime.Now)
second = DateTime.GetSecond(DateTime.Now)
line_csv = date & "," & hour & ":" & minute & ":" & second & "," & Label3.Text & "," & _
Label4.text & "," & lbl_acele & "," & lbl_orien & "," & lblLat.Text & "," & lblLon.Text & "," & lblSpeed.Text & CRLF
List1.Add(line_csv)
End Sub
Thanks in advance.
Regards