Relaunhing app only works every 2nd try
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Relaunhing app only works every 2nd try
Hi
After quitting my app on the device, relaunching it only works on every 2nd try. It otherwise only shows a black screen for a few seconds and then quits. Has anyone else had this problem?
I've noticed that each time I quit the app, the Application Manager would show that the app is still running, giving the option to "Force close" it. How can I get the app to close completely every time I quit it, so it would relaunch properly on every try and not just every 2nd try?
Thanks
Gerrie
After quitting my app on the device, relaunching it only works on every 2nd try. It otherwise only shows a black screen for a few seconds and then quits. Has anyone else had this problem?
I've noticed that each time I quit the app, the Application Manager would show that the app is still running, giving the option to "Force close" it. How can I get the app to close completely every time I quit it, so it would relaunch properly on every try and not just every 2nd try?
Thanks
Gerrie
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: Relaunhing app only works every 2nd try
By no means am I an expert, and I'm sure there's probably a better way, but it seems to work. Perhaps one of the LC gurus will chime in.
In my preOpenStack stack handler
and in my closeStack handler
In my preOpenStack stack handler
Code: Select all
set the destroyStack of this stack to true
Code: Select all
quit //instead of close stack
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: Relaunhing app only works every 2nd try
Sorry about waiting so long before posting this reply.
I did as Shawn suggested, but the problem persists. It seems as though the Android OS suspends the app before it could finish closing, and then when I try to launch the app again, the app is resumed and finishes closing instead of launching. Has anyone else had this happen?
- Gerrie
I did as Shawn suggested, but the problem persists. It seems as though the Android OS suspends the app before it could finish closing, and then when I try to launch the app again, the app is resumed and finishes closing instead of launching. Has anyone else had this happen?
- Gerrie
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: Relaunhing app only works every 2nd try
Hi,
A while ago, I encountered a similar issue, BUT, like shawnbic says, using
[1] the 'set the destroyStack of stack "MyStackName" to true' (for the main stack AND each sub-stack) and
[2] 'quit' seems to have remedied the issue...
Just my penny's worth...
(I was using LC commercial 6.6.2 on an ASUS 701 Infinity Transformer using ICS)
Let us know if this remedies your issue OR if you find a different 'work around' please.
HTH.
Trax.
A while ago, I encountered a similar issue, BUT, like shawnbic says, using
[1] the 'set the destroyStack of stack "MyStackName" to true' (for the main stack AND each sub-stack) and
[2] 'quit' seems to have remedied the issue...
Just my penny's worth...
(I was using LC commercial 6.6.2 on an ASUS 701 Infinity Transformer using ICS)
Let us know if this remedies your issue OR if you find a different 'work around' please.
HTH.
Trax.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: Relaunhing app only works every 2nd try
Trax, I tried your suggestion, but still no joy.
In my card script I have:
and in my stack script I have:
The above should work, right?
But in this particular app I'm working on, it doesn't work and I just can't figure out why.
In my card script I have:
Code: Select all
on backKey
exitTheApp
end backKey
Code: Select all
on exitTheApp
put the stacksinuse into tStacksInUse
repeat with i = 1 to the number of lines of tStacksInUse
stop using stack line i of tStacksInUse
end repeat
put the openStacks into tOpenStacks
repeat with i = 1 to the number of lines of tOpenStacks
set the destroyStack of stack line i of tOpenStacks to true
end repeat
quit
end exitTheApp
But in this particular app I'm working on, it doesn't work and I just can't figure out why.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: Relaunhing app only works every 2nd try
Hi Ledigimate,
I've not tried it your way specifically...
The major difference for me is that I script the
'set the destroyStack of stack "MyStackName" to true' in the 'preopenstack' handler
The only thing I can't prove here (without trying it) is whether you actually need to do half of what you're doing and whether after 'stop using stack...' the 'set destroystack...' command has any effect...
Three ideas :
[1] just an idea : place a 'wait for 1 second' just before the 'quit' - I doubt this will have any effect though - but possibly worth a try...
[2] relocate your 'destroystack...' repeat block BEFORE the 'stop using...' repeat block
[3] relocate the 'destroystack'...' repeat block to a preopenstack (main stack) handler and temporarily rem out all other lines except the 'quit' in the 'exitTheApp' handler.
Won't take more than 10 mins to do all three... let us know how you get on (my money's on [3] - for what it's worth !)
HTH.
Trax
I've not tried it your way specifically...
The major difference for me is that I script the
'set the destroyStack of stack "MyStackName" to true' in the 'preopenstack' handler
The only thing I can't prove here (without trying it) is whether you actually need to do half of what you're doing and whether after 'stop using stack...' the 'set destroystack...' command has any effect...
Three ideas :
[1] just an idea : place a 'wait for 1 second' just before the 'quit' - I doubt this will have any effect though - but possibly worth a try...
[2] relocate your 'destroystack...' repeat block BEFORE the 'stop using...' repeat block
[3] relocate the 'destroystack'...' repeat block to a preopenstack (main stack) handler and temporarily rem out all other lines except the 'quit' in the 'exitTheApp' handler.
Won't take more than 10 mins to do all three... let us know how you get on (my money's on [3] - for what it's worth !)
HTH.
Trax
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: Relaunhing app only works every 2nd try
Hello Trax,
I tried all three suggestions, but none of that helped. I also replaced the repeat block with explicit "set the destroystack of stack xyzStack to true" statements in case "the openStacks" returned empty.
I've made a backup of my stacks and now I'm deleting and commenting out piece by piece to try and narrow it down. So far I've removed 80% of the cards and code, and I removed all externals, but still no luck. I'll keep chopping off more of the app until I find what's causing it. If I end up with a single stack and a single card with nothing on it, and only three handlers - preOpenStack, backKey, and exitTheApp - and it still doesn't work, then I'll post what's left of my stack here for someone else to have a crack at it.
I tried all three suggestions, but none of that helped. I also replaced the repeat block with explicit "set the destroystack of stack xyzStack to true" statements in case "the openStacks" returned empty.
I've made a backup of my stacks and now I'm deleting and commenting out piece by piece to try and narrow it down. So far I've removed 80% of the cards and code, and I removed all externals, but still no luck. I'll keep chopping off more of the app until I find what's causing it. If I end up with a single stack and a single card with nothing on it, and only three handlers - preOpenStack, backKey, and exitTheApp - and it still doesn't work, then I'll post what's left of my stack here for someone else to have a crack at it.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: Relaunhing app only works every 2nd try
Remove the "quit" command. Android keeps the app in RAM until it needs to use the memory, so when you restart it immediately the script picks up where it left off (at least that's my theory.) At any rate, a specific quit instruction isn't needed, the OS manages that and LiveCode's default is to quit when the app is closed anyway.
For destroystack, I have my preferences set to create all new stacks with it set to true. Originally it was useful for faster reloading of stacks on slower machines but with today's processors it's unnecessary. For your existing stacks just set it to true in the property inspector, save the stack, and forget about it. There's no need to script it.
The destroystack setting on substacks is immaterial, they are never completely removed as long as the mainstack is open. They are part of the same file so they can't be completely removed.
For destroystack, I have my preferences set to create all new stacks with it set to true. Originally it was useful for faster reloading of stacks on slower machines but with today's processors it's unnecessary. For your existing stacks just set it to true in the property inspector, save the stack, and forget about it. There's no need to script it.
The destroystack setting on substacks is immaterial, they are never completely removed as long as the mainstack is open. They are part of the same file so they can't be completely removed.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Relaunhing app only works every 2nd try
Also there is a setting for stacks in the standalone creator options to set the destroyStack property. Is there a difference here in relation to the destroyStack property of a stack (as opposed to a standalone)?
Re: Relaunhing app only works every 2nd try
Good point. There isn't really a difference in the case of the mainstack. Destroystack would matter if the mainstack opened other document stacks that weren't part of the standalone file.SparkOut wrote:Also there is a setting for stacks in the standalone creator options to set the destroyStack property. Is there a difference here in relation to the destroyStack property of a stack (as opposed to a standalone)?
I wasn't thinking straight.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: Relaunhing app only works every 2nd try
Thanks for all the suggestions.
So if I understand you correctly, there's no need for me to close the app in a script because Android decides when to close the app, right?
But then, if the app picks up where it left off, that would create a problem. I need my app to start over every time it's launched, because the device it runs on is shared among users and the next user shouldn't pick up where the previous user left off. Otherwise I must find a way to make my app detect when it is being relaunched so it can start a new session. I've seen a "relaunch" message in the dictionary, but unfortunately it's not available on Android.
So if I understand you correctly, there's no need for me to close the app in a script because Android decides when to close the app, right?
But then, if the app picks up where it left off, that would create a problem. I need my app to start over every time it's launched, because the device it runs on is shared among users and the next user shouldn't pick up where the previous user left off. Otherwise I must find a way to make my app detect when it is being relaunched so it can start a new session. I've seen a "relaunch" message in the dictionary, but unfortunately it's not available on Android.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
-
- Posts: 73
- Joined: Mon Nov 12, 2012 4:13 pm
Re: Relaunhing app only works every 2nd try
Can't you use openStack command instead of the relaunch message?
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: Relaunhing app only works every 2nd try
@ChrisMikrow, I have an openStack handler in which a new session is started. The problem I'm having is that it only works every 2nd time the app is relaunched. On every odd relaunch the openStack handler is never called, but instead it only shows a black screen and quits after a few seconds.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: Relaunhing app only works every 2nd try
If the app is still resident in memory, you won't get an openStack message or a shutdown message, so it's hard to know when the app comes to the front again. If Android OS has shut down the app then those messages do occur. I haven't tried it, but you could see if you get a resumeStack message and if so, do your setup in that handler.
If that doesn't work you could try this:
but given the symptoms you describe, I'm not sure it will work.
Another thing to try is to trap the backKey message and do your cleanup there.
If that doesn't work you could try this:
Code: Select all
quit
exit to top
Another thing to try is to trap the backKey message and do your cleanup there.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com