Android - quitting application fails
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Android - quitting application fails
I've tried a few ways to close an app on Android - (attaching this code to a button)
close the defaultStack, close this stack, and quit --- all of them cause the app to freeze, and then android allows me to force quit the app after a few seconds.
I've tested this on both the emulator and directly on a phone with the same results.
Anybody seen this, or have suggestions on how to close the app successfully?
Thanks,
Mark
close the defaultStack, close this stack, and quit --- all of them cause the app to freeze, and then android allows me to force quit the app after a few seconds.
I've tested this on both the emulator and directly on a phone with the same results.
Anybody seen this, or have suggestions on how to close the app successfully?
Thanks,
Mark
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Android - quitting application fails
Well, it shouldn't crash like that, so that's a bug. But Android apps don't really quit, and you shouldn't even try. The Home hardware button will close your app and go back to the launcher screen. Android OS expects to control the app behavior, and manages all memory and the state on its own. It caches the app in RAM so that it can quick-start when the user goes back to it, and pulls it out of memory and shuts it down if it needs RAM or the app hasn't been used for a while. Very few apps try to control their own quitting process. In fact, there are special apps you can get whose only function is to quit any running processes, because apps are expected to stay resident. These utilities are now discouraged in Froyo (Android 2.2) because it interferes with the OS, so their use is now deprecated and unadvised.
The short answer is: let the user press the Home button to leave your app, and don't try to manage the process yourself.
The short answer is: let the user press the Home button to leave your app, and don't try to manage the process yourself.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Android - quitting application fails
Ok, thanks for the info, Jacque!
Re: Android - quitting application fails
It does crash. So whether or not closing is supposed to be handled by the app, it is a bug none-the-less.
I have found that the home button will take you to the home screen and leave any data on the app so if you return to it, any data entered in fields will still be there. It will also ignore the opencard/openstack message upon return. But if you hit the back button, it will actually "quit" the app, you will lose any data on the screen and the next time you open the app it will follow opencard/openstack message. This is on a Galaxy 3G with 2.2 FROYO.
I have found that the home button will take you to the home screen and leave any data on the app so if you return to it, any data entered in fields will still be there. It will also ignore the opencard/openstack message upon return. But if you hit the back button, it will actually "quit" the app, you will lose any data on the screen and the next time you open the app it will follow opencard/openstack message. This is on a Galaxy 3G with 2.2 FROYO.
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Android - quitting application fails
That's good to know, I hadn't realized there was a difference in the hardware button behaviors. The latest release of LiveCode sends a "backKey" message when that key is pressed, so you can trap that if you need to. I haven't tested to see if issuing a "quit" command on "backKey" will crash, but since it quits anyway I guess that's moot.
Hopefully soon we'll get a menu button and a Home button. I could use menus.
Hopefully soon we'll get a menu button and a Home button. I could use menus.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Android - quitting application fails
I use an Android tablet with 2.3.3. Almost all the apps I have display an app-specific menu when I press the system Menu button. Can such a menu be constructed for an LC app?
sp27
sp27
-
- VIP Livecode Opensource Backer
- Posts: 75
- Joined: Wed Mar 09, 2011 6:48 pm
- Location: Northern California
Re: Android - quitting application fails
My experience on my Samsung Captivate running FROYO 2.2.1 is the same as Paul D's, except for the crash. With all the other commercial apps I have run, the "Back Key" will act much like the back button on a browser, retreating to the previous page in the app until it reaches the top level, where the app truly quits, and displays the home screen. As he says, the "Home" button will take you to the home screen, but you can go back to your app without losing your data or place in the app.Paul D wrote:It does crash. So whether or not closing is supposed to be handled by the app, it is a bug none-the-less.
I have found that the home button will take you to the home screen and leave any data on the app so if you return to it, any data entered in fields will still be there. It will also ignore the opencard/openstack message upon return. But if you hit the back button, it will actually "quit" the app, you will lose any data on the screen and the next time you open the app it will follow opencard/openstack message. This is on a Galaxy 3G with 2.2 FROYO.
I tried the options originally posted by semiplay (close the defaultStack, close this stack, and quit), and they do not crash, or cause a force close on the Samsung. The screen displays the program listing without obviously crashing. HOWEVER, attempting to relaunch the test app again from the program screen consistently produced (for me) a black screen that then freezes. From there, I have been able to get to a program that will "kill" apps. When applied to the test program loaded on the phone, all is well again. I have read the same type of literature that Jacque cited, so apparently, the Android OS sincerely wants to manage the opening and closing of apps (and memory management) on its own, without any interference.
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Android - quitting application fails
The black screen on startup if the app is in RAM is a known bug but it was supposed to be fixed in 4.6.1. But sometimes I still see it. Might be worth a bug report if there isn't one already.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com