'Timer Always Fires' is for those Apps that need a timer to continue even when they are off-screen, which probably does not apply to your App. Why did you choose a 30 millisecond time interval?
Best to follow SteveJG's advice and do a search for Stop Watch (might be examples in the Gallery too) to see how to code one accurately.
I think the crash occurs because the Clock Timer Block (+ procedure) has not finished processing before it is called again.
Edit: Actually, since your timer can get into hours, 'Timer Always Fires' is appropriate.
Anke
July 8, 2022, 9:46pm
7
What exactly is happening? What does crash mean? Do you get an error message?
Post the aia.
Set your timer interval to 1000
1000ms = 1 second
App should then run....
1 Like
Anke
July 8, 2022, 10:15pm
9
Try this one (TimerInterval=30
):
stopwatch_Anke.aia (6.9 KB)
Ray_Li
July 8, 2022, 10:20pm
10
Where do I find this block?
Also, the error that pops up on my phone says, "MIT AI2 Companion has stopped"
Anke
July 8, 2022, 10:21pm
11
In my app (aia). And search for "TFormat" extension.
Here is an extension to format the time / duration (millis) in different ways:
→ [ HH:mm:ss ] → [ days + HH:mm:ss ] → [ HH:mm ] → [ mm:ss ] → etc.
This is asked very often and always requires a lot of questions / answers and posts in the forum.
(Last here: Creating a Chronometer - #17 by PizzaGuy07 )
Hence this extension (some of it can also be implemented with the on-board methods, but I want to simplify it:):
Version 1 (May 20, 2020):
TFormat.aix (5.5 KB)
Version 2 (Oct 20, 2021):
TForm…
Anke
July 8, 2022, 10:24pm
12
Works fine on my test devices.
What device and which Android version?
Anke
July 8, 2022, 10:28pm
14
Build the APK and try ...
Ray_Li
July 8, 2022, 10:36pm
16
Version 2.63
Also building the APK gives this error:
App Inventor is unable to compile this project.
The compiler error output was
________Preparing application icon
________Creating animation xml
________Creating style xml
________Creating provider_path xml
________Creating network_security_config xml
________Generating adaptive icon file
________Generating round adaptive icon file
________Generating adaptive icon background file
________Generating manifest file
________Attaching native libraries
________Attaching Android Archive (AAR) libraries
________Attaching component assets
________Invoking AAPT
AAPT time: 2.163 seconds
________Compiling source files
(compiling appinventor/ai_herui_ray_li/stopwatch/Screen1.yail to appinventor.ai_herui_ray_li.stopwatch.Screen1)
ERROR: appinventor/ai_herui_ray_li/stopwatch/Screen1.yail line 87: call to 'set-and-coerce-property!' has too few arguments (3; must be 4)
Kawa compile time: 3.286 seconds
.
Ray_Li
July 8, 2022, 10:37pm
17
I've downloaded the extension, how do I get the blocks in my app?
Anke
July 8, 2022, 10:41pm
18
No problem to build the APK, try this:
I also tried my app (Companion & APK) on a very old Android 5 device. Works fine!
Ray_Li
July 8, 2022, 10:44pm
19
Where do I go to run the APK file that you uploaded?
Anke
July 8, 2022, 10:48pm
20
Download it to your computer, copy it to your test device and install.
Ray, you don't have to use an extension:
StopWatchHMS.aia (4.3 KB)
Ray_Li
July 8, 2022, 10:56pm
22
Seems like your test works for me too...
Anke
July 8, 2022, 10:57pm
23
So where is your problem?
It should also work with Companion.
Ray_Li
July 8, 2022, 11:06pm
25
I've resolved the issue, but thanks for your help, I appreciate it!