running in background

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: running in background

Post by SparkOut » Mon May 11, 2020 6:15 pm

jacque wrote:
Mon Apr 27, 2020 6:49 am
I can't think of an easy solution. Android will shut down your app if it needs the memory (and I think iOS does too,) so if your user doesn't open your app for a while it will stop unless your external device keeps it running. If that's the case, I'm not sure there is an answer. When the OS closes your app you will get a "shutdown" message, but that's the only message LC sends when the app is in the background.

If you have a paid version of LC you are entitled to tech support. You might write to support@livecode.com and ask if they have a solution. If they do, I would love to hear it.
Maybe not a fix for background running, but a pause and resume message may now be possible
LiveCode 9.6.0-rc-1 Release Notes wrote: Android Utilities module Registering for lifecycle SensorEventListener
A new handler AndroidRegisterLifecycleListener has been added that allows for widgets to track application lifecycle events, specifying handlers to be called when the application is paused or resumed. The first parameter is the handler to be called when the application is paused. The second parameter is the handler to be called when the application is resumed. The listener object returned by AndroidRegisterLifecycleListener can be unregistered by calling AndroidUnregisterLifecycleListener, meaning the pause and resume handlers will no longer be called.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7230
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: running in background

Post by jacque » Mon May 11, 2020 8:16 pm

Wow. I've been waiting my whole LC career for those messages!
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: running in background

Post by bogs » Tue May 12, 2020 9:45 am

Wow. I've been waiting my whole LC career for those messages!
**Who are you, and what have you done with Jacque ?

Actually, I suppose that would depend on when you consider Rev(olution) to have changed over to Lc, but 4.5, which is listed on the download pages, has no mobile development tab in the standalone options (although it *does* have the revWeb build option~!!)
aPic_RevOrLc.png
Silver and gold, silver and gold...
{Beat that for nit-picky Gaddy :P }

** Just some gentle ribbing, I am preparing for school today, and dealing with the children in class always brings out the worst in me.
Image

tim2RZ
Posts: 6
Joined: Tue Mar 10, 2020 12:27 am

Re: running in background

Post by tim2RZ » Tue May 12, 2020 11:23 am

I can't think of an easy solution. Android will shut down your app if it needs the memory (and I think iOS does too,) so if your user doesn't open your app for a while it will stop unless your external device keeps it running. If that's the case, I'm not sure there is an answer. When the OS closes your app you will get a "shutdown" message, but that's the only message LC sends when the app is in the background.
As I know iOS will do the same, it's not about Android itself.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7230
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: running in background

Post by jacque » Tue May 12, 2020 5:31 pm

bogs wrote:
Tue May 12, 2020 9:45 am
Wow. I've been waiting my whole LC career for those messages!
**Who are you, and what have you done with Jacque ?
You obviously have not heard about my time-warp stack which has come up on the mailing list periodically over the years. Aside from some issues with the chronometer, which can occasionally dump you into unexpected time periods, it's fair to say that I sometimes lose track of just exactly when I am. I will have debugged and fixed that problem in a few years.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: running in background

Post by bogs » Tue May 12, 2020 5:35 pm

So your saying you solved that 3 decades before Hypercard was created, right? :twisted:
Image

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: running in background

Post by trevix » Tue May 12, 2020 5:42 pm

I am not sure how to use this "AndroidRegisterLifecycleListener".
I tested it putting this on the Preopenstack, but it stops the opening script

Code: Select all

...
AndroidRegisterLifecycleListener ApplicationPaused, ApplicationResumed
...
So I guess it is

Code: Select all

on AndroidRegisterLifecycleListener ApplicationPaused, ApplicationResumed

end 

on ApplicationPaused
     do something
end ApplicationPaused

on ApplicationResumed
     do something
end ApplicationResumed
But id doesn't work.
No help on the dictionary.
Android 5.5 , LC 9.6.0 RC1
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: running in background

Post by trevix » Tue May 12, 2020 5:45 pm

Or is this just for Widgets?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: running in background

Post by trevix » Tue May 12, 2020 5:49 pm

Ah,Aaaah. LCB
I wonder if a library extension can be built with the dictionary example (of LCB)
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: running in background

Post by LCMark » Tue May 12, 2020 6:04 pm

@trevix: Yes this is currently a hook which is only accessible from LCB.

It was motivated by both your FLIC button library (so that we could make it work the same as iOS), and by the barcode scanner where we now use a device's light sensor to perform 'auto' torchMode. (Android strongly suggests that any hardware features not needed whilst the app is in the background be turned off between suspend and resume - iOS does that automatically as the OS doesn't do anything with your app in the background unless you've explicitly asked).

It would be easy enough to wrap in an LCB library which just posts suspend and resume (or similar messages) to enable script to access those lifecycle events...

That being said, we have got an internal patch for suspend/resume for iOS and Android in LCS but it needs a bit more validation (mobile app lifecycle events are a bit of a bed of thorns) and I didn't think it wise to suddenly start firing suspend/resume messages in an RC which never fired on those platforms before! All being we will add engine support for suspend/resume LCS messages on mobile in 9.7 (the dev cycle of which should give people ample time to check what they have in such things currently which might not be appropriate for mobile!).

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: running in background

Post by trevix » Tue May 12, 2020 6:34 pm

Thanks.
iOS does that automatically as the OS doesn't do anything with your app in the background unless you've explicitly asked
In the Fliccase it desn't matter. Pause detection is needed because otherwise external bluetooth device stay connected for days, consuming more battery then needed. It is used to shut off and, eventually, to restablish connection.
And send in time in background (using it like a timer for not-use) doesn't work on iOS
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”