Page 1 of 1

Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 1:07 pm
by Opaquer
Hey all!

I'm currently in the final stages of my sudoku app (I say that, but in reality I'll probably find a bunch of things needed to do before it's actually done!), and one thing I've added is a timer to see how long you take on sudokus.

The issue is that when I lock my screen, or change apps and back again, the timer continues to run instead of stopping. I have this code running in my card script to update the timer:

Code: Select all

on updateTimer
   if sFlag is true then 
      add 1 to timeElapsed
      calculateTime timeElapsed
      send "updateTimer" to me in 1 second
   end if
end updateTimer
And I set sFlag to true/false depending on whether I want the timer running or not.

Is there a way that LC can know when something happens like changing apps, going to the home screen or locking the screen, and set sFlag to false? Is it something simple, like an inclusion that's needed that automatically sleeps the app when it's not in focus or something like that? The closest I've found is the mobile idle timer, but that just keeps the screen on, but doesn't help with seeing what happens when apps change etc?

If it makes a difference, I'm running Android

Many thanks in advanced!

Re: Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 1:36 pm
by dunbarx
Hi.

Would the "suspendStack" message be of use here?

Craig

Re: Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 1:42 pm
by Klaus
Nope! From the dictionary:
suspendstack
...
OS -> mac, windows, linux
Platforms -> desktop, server
Same for iconic etc...

Re: Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 2:12 pm
by Opaquer
I think I either saw something like "SuspendStack" or similar in the dictionary and found it was only for desktop too, which was a shame :(. There didn't seem to be a similar thing for mobile that I could find unfortunately

Re: Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 3:14 pm
by SparkOut
It might be coming
viewtopic.php?f=8&t=32573&p=191546#p191580

Just don't get in front of jacque in the queue - she gets first dibs on this one.

Re: Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 3:24 pm
by Opaquer
So, it's getting quite late where I am so I just want to make sure that I've got it right: there's currently something in testing that can only be used in LCB to find out when an application has been put into the background on android? I've never used LCB so have no idea how it works - that might be my next step... or, you know, remove the timer in the app for now. It seems like every step I've been taking forward with this app, I take 1.5 steps backwards as I discover new things I need to figure out and do with it! Definitely fun, but also a challenge!

Re: Making app stop running when I lock my phone/change apps

Posted: Thu Aug 20, 2020 4:26 pm
by jacque
SparkOut wrote:
Thu Aug 20, 2020 3:14 pm
It might be coming
viewtopic.php?f=8&t=32573&p=191546#p191580

Just don't get in front of jacque in the queue - she gets first dibs on this one.
I'll be the one sleeping in line on the sidewalk all night, waiting for the release. But you're welcome to sit behind me.

Re: Making app stop running when I lock my phone/change apps

Posted: Sat Aug 22, 2020 2:44 am
by Opaquer
It definitely sounds like you've been waiting for this for a while, Jacque!

How does LCB work? Is it the same language as LC, and thus something that can be made relatively easily? Or is it a different language completely and we'll have to wait for someone who knows it to make it for us?

Re: Making app stop running when I lock my phone/change apps

Posted: Sat Aug 22, 2020 5:13 pm
by jacque
LCB is both similar to LCS and different. The syntax is similar but the execution is different. Some keywords are unique to it, you must declare variables, and the language is strongly typed.

It's different enough that I haven't learned it yet but some others here have.