Android Question Error in delayed service

Manuel Puerta Sánchez

Member
Licensed User
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):
Sub Service_Start (StartingIntent As Intent)
StartServiceAt("", DateTime.Now + 2 * DateTime.TicksPerSecond, True)
CallSubDelayed(Main, "registro_file")
End Sub​
- Main (Activity):
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
This is enought information? Is this a correct implementation for 2 second service loop?

Thanks in advance.
Regards
 

DonManfred

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