11-08-2022 07:06 - edited 11-12-2022 10:54
11-08-2022 07:06 - edited 11-12-2022 10:54
Hi,
I'm in developing process of an exercise App for my Versa 2. Is it possible to switch off the functionality that the app is closed after 2 minutes in the background?
That would be helpful...
My second question is, is it possible that the user cannot exit the app while a workout is in progress?
This is still somewhat a problem in the functionality of the app...
Kind regards,
Oin
11-08-2022 11:18
11-08-2022 11:18
1. Set appTimeoutEnabled to false.
2. You can intercept physical button presses and handle them how you want, then call preventDefault() on the event to stop the system from doing its thing.
11-08-2022 12:00
11-08-2022 12:00
Okay, thank you for your quick reply!
I'll try that next time when i'm working on it.
Kind Regards,
Oin
11-10-2022 07:42
11-10-2022 07:42
Everything worked perfectly!
Thank you!
I have another question:
If I select my own workout type in the exercise API, it's always saved as Aerobic. Do anyone know a workaround for that problem?
11-10-2022 10:54 - edited 11-10-2022 11:04
11-10-2022 10:54 - edited 11-10-2022 11:04
I saw the first person who reported this problem wrote the report in 2020. Why is there no Fix two years later?!
The Fitbit mobile App needs an update, otherwise my app will not be useable.
I just saw that there is an Indoor-Climbing Mode for the Fitbit Mobile App? How can I address it?
Kind regards,
Oin
11-12-2022 10:57
11-12-2022 10:57
Hello again!
I've tried the solutions from @Gondwana for my problem, but the app is always killed after 5 minutes, although I set the appTimeoutEnabled = false into an interval of 2 minutes. Does anyone know why that is so?
Regards,
Oin
11-12-2022 11:17
11-12-2022 11:17
@Oin wrote:Hello again!
...I set the appTimeoutEnabled = false into an interval of 2 minutes...
What does this mean? A code snippet might help.
11-12-2022 11:44
11-12-2022 11:44
import { me as appbit } from "appbit"
//Prevent the app from killing in the background
appbit.appTimeoutEnabled = false;
setInterval(() => {
appbit.appTimeoutEnabled = false;
}, 100000);
That is my code.
11-12-2022 11:47 - edited 11-12-2022 11:47
11-12-2022 11:47 - edited 11-12-2022 11:47
I also set the "run_background" permission in the package.json. I don't know exactly why. If I activated the Developer Bridge, it works without problems for 10 minutes and more. Maybe the Dev Bridge keeps the SmartWatch active?
11-12-2022 11:51
11-12-2022 11:51
Thanks.
The setInterval shouldn't be necessary. Once the value has been set to false, it should stick (although it may be misreported if read).
I'm wondering if the app might be closing because it's unresponsive or out of memory.
run_background shouldn't directly affect the watch (device) code, but only the companion code.
It would be interesting to know if the time to close is always exactly the same, and a round value.
11-12-2022 11:56
11-12-2022 11:56
It's always around 4 minutes. I let it go for 15 minutes with the Fitbit CLI opened and I checked the memory every five seconds. Around ¼ of JS Memory are needed to run my application. I'll remove the setInterval and look if it's working
11-12-2022 11:57
11-12-2022 11:57
It just occurred to me that '...in the background' sounds odd. No third-party app can run in the background on the device (watch).
The companion component is different.
11-12-2022 11:59
11-12-2022 11:59
But there are also other third-party exercise apps, how can they do that? There must be a solution we don't know, but the others. Is there a way to ping the application on the app in a few intervals to stay it awake?
11-12-2022 12:07
11-12-2022 12:07
I wonder if we're struggling with terminology. I'm not aware of any exercise app that keeps running while some other app or clockface is running in the foreground. Even Fitbit's Exercise app closes when something else is started.
With appTimeoutEnabled false, an app should be able to run indefinitely as long as the user doesn't start any other app or clockface.
Display going off isn't the same as background (but you probably knew that).
11-12-2022 12:09
11-12-2022 12:09
I'm aware of that the app cannot run while another app is opened. But the app is terminated from the system after a few minutes...
11-12-2022 12:16 - edited 11-12-2022 12:17
11-12-2022 12:16 - edited 11-12-2022 12:17
Hm... you're importing as `me` but then set on appbit🤔
11-12-2022 12:18
11-12-2022 12:18
That's what I read in another post in this forum...
Maybe I should set it to "me" again.
11-12-2022 12:22
11-12-2022 12:22
No, I just realized you're import us correct. Sorry for confusing
11-12-2022 12:23
11-12-2022 12:23
I think the appTimeoutEnabled code is okay. It seems to be working.
11-12-2022 12:24
11-12-2022 12:24
No problem. I'm no professional JS programmer, It's only a (for somebody) strange kind of hobby..