The stop it appears after I press start, after I press stop the resume button appears. All in the same place
- Create a procedure from the blocks you have in the "starstopBTN' event.
- In these blocks, where you set the global variable timeStarted to false and true, also save this value in TinyDb under a tag, e.g. "started".
- Add a call to this procedure both to the "startstopBTN.Click" button and to "Screen.Initialize".
- In the "Screen.Initialize" event, also add the value from TinyDb from the "started" tag to the "timerStarted" variable.
Can you please show me in pictures how?
Also, what happens when the home button is pressed or the device goes into sleep mode? If the stopwatch should run for a few minutes, Doze mode intervenes and will throttle the timer and then stop it.
Furthermore, the timer is very imprecise and loses at least 1 second per minute. The timer must therefore be regularly adjusted to the system time. (This topic is as old as App Inventor.)
Here is a small test app with which you can start, pause and stop/reset the stopwatch. The blue time display is generated via a clock component. The red time display is generated via a precise stopwatch extension.
I've tried it for over an hour and it works, just like kevinkun showed.
After reopening the application I have to press start for it to start showing where it is in the count.
Your pointing out that there is such a big difference between the two you show, I want to ask on what I have and after I put your extension in, what do I need to do to the blocks with this extension so that it counts with this extension?
And again...
Test with the APK and do not use a USB charging cable during this.
And...You are asking a question again that I answered. You didn't even try to modify the blocks according to my description.
Fix one problem first. You can then address the accuracy issue Anke points out. Doing everything at once will make it difficult to respond to the problems you present.
We've debated this before, I think all it takes is a small modification to your test project for the built-in clock to make it work fine without an extension.
this only happens when you are adding up the timerInterval to count time.
In this example, I compare the now time with the start time to calculate the time collapse,the deviation will not getting biger and bigger.
Exactly, the Timer event is intended only to display the time, not to count.
You see the result of this format Date or Time function is different. it depends on the Time zone, since I am in China (east 8th zone).
Therefore I need to minus the timezone offset.
Yes, in Europe we have a winter shift of +1 and a summer shift of +2.
I used it while walking and closed the app, then the device went to sleep.
When I revisited this application, it continued to count tirelessly
I also tried your example and there I saw that the difference between the two is big
- Create a procedure from the blocks you have in the "starstopBTN' event.
- In these blocks, where you set the global variable timeStarted to false and true, also save this value in TinyDb under a tag, e.g. "started".
- Add a call to this procedure both to the "startstopBTN.Click" button and to "Screen.Initialize".
- In the "Screen.Initialize" event, also add the value from TinyDb from the "started" tag to the "timerStarted" variable.
I read it and re-read it at the beginning, I tried to make something out of what I understood, but I couldn't do anything
If I knew exactly how it was done, I would have done it...
- Procedure is a purple block taken from the procedure drawer. Give it a name and place your blocks from the startstopBTN.Click event in it.
Do you understand now?
yes I will try it now
-
Once you have created this procedure, you need to call it in the startstopBTN.Click and Screen2.Initialize events.
-
Create 2 TinyDb.StoreValue blocks. Tag - "started". One block with the value true, the other with the value false.