Android Question How to write values after x minutes

apty

Active Member
Licensed User
Longtime User
I have the following code for writing accelerometer values.
B4X:
Sub Accelerometer_AccelerometerChanged (X As Float, Y As Float, Z As Float)
Dim Ax As Float
Dim Ay As Float
Dim Az As Float
Ax=X
Ay=Y
Az=Z
xval.Text=Ax
yval.Text=Ay
zval.Text=Az
'
For i = 1 To 10
        WriteTextWriter(xval.Text&","&yval.Text&","&zval.Tex)
    Next
I would like to write this values after every 10 minutes. Please help..am stuck
 

stevel05

Expert
Licensed User
Longtime User
If you want it to run in the background have a look at services and ServiceStartAt, if you want it to run only when your app is active, you can use a timer.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Save the values to global variables, then in the timer_tick sub, write them. Or you could use a service anyway, and start it every 10 minutes while the app is running. That would save the accelerometer being read continuously.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Or if you don't want to create a service you could try calling StartListening in a timer_tick event and stop listening once the data has been written by your existing sub.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…