run in background?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
run in background?
Can an app be made to run in background, i.e. user starts app then closes it and/or switches off iPhone with slider and app still runs and does things specified at specified time intervals? Also, if possible, how to minimize battery usage?
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: run in background?
Most tasks can be done in the background on Android, but iOS limits the range of background tasks to a very few specific operations.uneu wrote:Can an app be made to run in background, i.e. user starts app then closes it and/or switches off iPhone with slider and app still runs and does things specified at specified time intervals? Also, if possible, how to minimize battery usage?
The range of tasks an app can do in the background on iOS has increased considerably in v5 over v4, but is still quite limited.
Given the ever-changing specs with iOS, you'll need to refer to the docs at developer.apple.com to learn which specific tasks are allowed in the background at this time.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: run in background?
Thanks, so just iOS restrictions apply. Is there anything that has to be specified in LiveCode or do those tasks that can run in background do so regardless once they are running?
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: run in background?
There are also some restrictions for background processes on Android as well, since any mobile OS will need to monitor processes to maintain good memory and power management. iOS is by far the more restrictive of the two, but a developer will want to be aware of such limitations and account for them in the program as much as possible.uneu wrote:Thanks, so just iOS restrictions apply.
It's hard to guess exactly how such limitations can come into play with your specific app without first knowing the details of what your app wants to do in the background, what it needs to do, how it might be able to take advantage of suspend/resume schemes if the OS kills it while its in the background, and the specific limitations of each OS.
To learn more you may want to review the LiveCode docs for those platforms carefully, and consider reviewing the sections of the Apple and Android dev sites which may apply to what you want to do.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: run in background?
i tried a very simple experiment: a stack with 1 button and 1 script that increase a field's value by 1 every second
i run the stack in the simulator then i click the home button, then i open the stack again and the field has "0" in it
so, a simple script inside the stack don't run on background, i was planning to make an app working mostly in background...i have to trash the idea?
i run the stack in the simulator then i click the home button, then i open the stack again and the field has "0" in it
so, a simple script inside the stack don't run on background, i was planning to make an app working mostly in background...i have to trash the idea?
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989
Re: run in background?
LC does not allow for multitasking, so to me background is not possible. Whenever you come back to your app the engine restarts and your app also.
Am I wrong
I would also love these features in LC on iOS
Am I wrong
I would also love these features in LC on iOS
Re: run in background?
You are not wrong.macnomad2 wrote:LC does not allow for multitasking, so to me background is not possible. Whenever you come back to your app the engine restarts and your app also.
Am I wrong
I would also love these features in LC on iOS
Re: run in background?
so, how i can trap the "go to homescreen" action on the iphone? the stack actually is close instead of paused, like others app, and i have to bring the user back where he/she was at the moment s/he pushes the home button... how to save the app "state" (as text) just the moment the app is closing? 

how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989
Re: run in background?
Hi...
When your stack is closing.. then write the number of the card that you are presently on to a file in the documents folder... then when the app is started again, read the file, which will contain the number of the card you were on before the stack closed and then go to it...
I use this a lot
be well
Dixie
When your stack is closing.. then write the number of the card that you are presently on to a file in the documents folder... then when the app is started again, read the file, which will contain the number of the card you were on before the stack closed and then go to it...
I use this a lot
be well
Dixie
Re: run in background?
Hi Tzenobite,
I use on in a stack script. Works well if someone presses the home button.
Kind regards
Bernd
I use on
Code: Select all
shutDown
-- save what you want to save
end shutDown
Kind regards
Bernd
Re: run in background?
i've already found this in the dictionary.... did you tried it in a real app? running this code in the simulator do nothing...
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989
Re: run in background?
Hi tzenobite,
what is your code?
Just saw that in my code example above of course it has to be
This worked for me in the simulator and on a real device. Actually it was the only way I found to trap for the shutting down of the app by pressing the Home button. This was a while back and may have changed.
Kind regards
Bernd
what is your code?
Just saw that in my code example above of course it has to be
Code: Select all
on shutDown
-- code
end shutDown
Kind regards
Bernd
Re: run in background?
Can't you use local notifications (in v 5.5) to trigger actions at specific times, even if the app is closed?
g
g
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: run in background?
in my stack i have simply:
but the stack says nothing 
Code: Select all
on shutDown
answer "hi"
end shutDown

how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989
Re: run in background?
just tried: for some reasons i ignore, the stack can write to a file while closing but can't do something "physical" like an anwer dialog
anyway, this will work for me, thanks again to all you nice people

anyway, this will work for me, thanks again to all you nice people

how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989