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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

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

Post by Opaquer » Thu Aug 20, 2020 1:07 pm

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!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Thu Aug 20, 2020 1:36 pm

Hi.

Would the "suspendStack" message be of use here?

Craig

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu Aug 20, 2020 1:42 pm

Nope! From the dictionary:
suspendstack
...
OS -> mac, windows, linux
Platforms -> desktop, server
Same for iconic etc...

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

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

Post by Opaquer » Thu Aug 20, 2020 2:12 pm

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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut » 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.

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

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

Post by Opaquer » Thu Aug 20, 2020 3:24 pm

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!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

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

Post by jacque » Thu Aug 20, 2020 4:26 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

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

Post by Opaquer » Sat Aug 22, 2020 2:44 am

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?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

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

Post by jacque » Sat Aug 22, 2020 5:13 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply