Know if the app in Android has been in the background?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Know if the app in Android has been in the background?
Hi all,
Does anyone know a way to know if an app in Android has been in the background and then came back to the foreground?
Does anyone know a way to know if an app in Android has been in the background and then came back to the foreground?
Re: Know if the app in Android has been in the background?
Hi,
The last time when I made an app for Android, it behaved as if it always restarted when it cam back to front. I just saved the current state of the app in a text file on closeStack or shutdown and rebuilt that state when the stack re-opened.
Kind regards,
Mark
The last time when I made an app for Android, it behaved as if it always restarted when it cam back to front. I just saved the current state of the app in a text file on closeStack or shutdown and rebuilt that state when the stack re-opened.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Know if the app in Android has been in the background?
Hi Mark, thank you for your replay. In my tests the previous app continue to run after you start using a new app (for example if the app is playing a song, the song continue to play in bg), maybe it's time I do new tests, things could are changed since the new releases of LC.
Re: Know if the app in Android has been in the background?
Hi Mag,
Actually, I did a test and it seems that LiveCode apps are now paused instead of aborted, from 6.? onwards.
Kind regards,
Mark
Actually, I did a test and it seems that LiveCode apps are now paused instead of aborted, from 6.? onwards.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Know if the app in Android has been in the background?
Android does not shut down apps unless it need the memory or system resources, or if your app quits when the user presses the Back button to go to the launcher. Usually the app will continue running for at least a little while and it will quit and be erased from RAM at an undetermined time. It depends on what the user does, how many other apps the user opens, and many other factors.
The safest way to deal with the problem is to always save the current state before shutdown, and restore it again when the app restarts.
The safest way to deal with the problem is to always save the current state before shutdown, and restore it again when the app restarts.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Know if the app in Android has been in the background?
Hi Jaque,
Android doesn't shut down apps, but LiveCode apps used to quit instead of pause when going into background mode. This seems to have been fixed somewhere between 5.5 and 6.1.
Kind regards,
Mark
Android doesn't shut down apps, but LiveCode apps used to quit instead of pause when going into background mode. This seems to have been fixed somewhere between 5.5 and 6.1.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Know if the app in Android has been in the background?
Hi Jacque, thank you for the explanation, it 'something that actually knew which is the reason of this post (reading the other post I tough that something is changed in new versions). So, now I can back to my original question: somebody knows if there is a way to know when the app goes in bg/it's running in bg?
Last edited by Mag on Mon Nov 18, 2013 9:26 pm, edited 2 times in total.
Re: Know if the app in Android has been in the background?
Hi Mag,
From my research I found the answer to be No.
I had a game that played music and could not find a way to tell if the game was in focus (or backgrounded) so the music kept playing even when the app was not in focus.
Simon
From my research I found the answer to be No.
I had a game that played music and could not find a way to tell if the game was in focus (or backgrounded) so the music kept playing even when the app was not in focus.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Know if the app in Android has been in the background?
I Simon, surely there is something that changes when the app is in background. We have just to find it.
Last edited by Mag on Tue Nov 19, 2013 10:07 am, edited 2 times in total.
Re: Know if the app in Android has been in the background?
Jacque, so the app quits when the user presses the Back button? Interesting, I thought the app does not shut even in that case.
Re: Know if the app in Android has been in the background?
It's been a while since I made an Android app so I could be wrong on that. I just tried to test it on my last app but of course I can't tell because I've got it saving the state when the Back button is pressed.Mag wrote:Jacque, so the app quits when the user presses the Back button? Interesting, I thought the app does not shut even in that case.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Know if the app in Android has been in the background?
Hi,
I just did a quick test on my Android 2.3.3 device. I don't see a way to stop an application other than to force quit it in the application manager. I can press the home and back buttons on the device or the back button on the screen but nothing stops the app.
Kind regards,
Mark
I just did a quick test on my Android 2.3.3 device. I don't see a way to stop an application other than to force quit it in the application manager. I can press the home and back buttons on the device or the back button on the screen but nothing stops the app.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Know if the app in Android has been in the background?
The Back, Menu and Search buttons can be trapped and with the Back, on closeStack or any of the others can be acted upon.
But the Home button is the problem.
Simon
But the Home button is the problem.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!