Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

App killed in the Background

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

Best Answer
0 Votes
22 REPLIES 22

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Okay, thank you for your quick reply!

I'll try that next time when i'm working on it.

 

Kind Regards,

Oin

 

 

Best Answer
0 Votes

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? 

Best Answer
0 Votes

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

Best Answer
0 Votes

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

Best Answer
0 Votes

@Oin wrote:

Hello again!

 

...I set the appTimeoutEnabled = false into an interval of 2 minutes...

What does this mean? A code snippet might help.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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.

Best Answer
0 Votes

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?

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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?

 

Best Answer
0 Votes

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).

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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...

Best Answer
0 Votes

Hm... you're importing as `me` but then set on appbit🤔

Best Answer
0 Votes

That's what I read in another post in this forum...

Maybe I should set it to "me" again.

Best Answer
0 Votes

No, I just realized you're import us correct. Sorry for confusing

Best Answer
0 Votes

I think the appTimeoutEnabled code is okay. It seems to be working.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

No problem. I'm no professional JS programmer, It's only a (for somebody) strange kind of hobby..

Best Answer
0 Votes