Making app stop running when I lock my phone/change apps
Posted: 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:
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!
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
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!