timers and date/ticks questions

sorex

Expert
Licensed User
Longtime User
Hello,

I'm doing some testing with timers and date/time/ticks.

1.
this is more a request than a question but is it possible to add the timer 'view' in the designer's add option? like you can do in VB6.

2.
I have a small timer running which I can start and pause etc
just fine by pressing a button.

but when the screenlock gets activated after 10 seconds and I unlock
the screen the timer seems to have paused where the lock happened.
how do I let my timer keep running even when the screen is locked?


3.
I have a small piece of code here, plain and simple but for some reason
both labels show either 01:00:00 and 1 , shouldn't this be 00:00:00 & 0 ?

B4X:
starttime=0
Label1.Text=DateTime.Time(starttime) 
Label2.Text=DateTime.GetHour(starttime)
 

sorex

Expert
Licensed User
Longtime User
1. ok, so I prolly mis a lot of stuff I didn't know about since I relied on what I saw in the designer>add view menu. will go through the guides again for this.

2. will do some research on that

3. oh, offset 0 is GMT then I presume? thanks for the hint!
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
the editor didn't list the settimezoneoffset command, but DateTime.SetTimeZone(0) solved my issue.


I also had a look at your service docs/tutorial.

But if I interpret it right that does mean that I need to reschedule the service every second to make sure my timer updates right (keeps counting) ?

Or can I leave the service running with an internal timer that updates a counter every second?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
no, not really.

It's just a small sports app I'm doing and it should keep running even when the phone is locked or the app not visible.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I took schimanski's example and rewrote it to my needs. (service + timer)

Now it keeps running/counting when going into locked state or when pressing the home button to check my mails and go back to the app.

Didn't see it appearing in that pull down status menu tho, will have a look at that later.

Thank Erel & schimanski for the info & examples.
 
Upvote 0
Top