Android won't quit

Ralph DiMola rdimola at evergreeninfo.net
Thu Jun 7 13:49:13 EDT 2018


This is not an easy thing to fix and can be broken easily. The app in memory is not corrupt but the restart of the app is probably exposing an LC engine bug.

Details for geeks...

To handle the Android unique app restart protocol: After you "Quit" or the app gets hibernated so to speak by the OS, the state of Activities, Fragments and Views will be saved. When returning back to the application , the system will start the process again, recreate the top activity. and you will get a Bundle with the stored state. This is where thing can go sideways,  the whole process was killed. So any Singletons (or any “application scope” objects), any temporary data, any data stored in “retained Fragments” ... Everything will be in a state as if the app was just launched , with one big difference , the state is restored and the app is at the point where you left the app. If the Activity you are depending on has some shared Object, or some injected dependency where you keep recent data then most likely the application will just crash on a NullPointerException because it didn’t expect the data to be null.

The Android OS is designed not to allow apps to be "stopped/killed" like desktop apps. That is why in the Application Manager it's call "Force stop". To work around the OS design (limitation?) LC could initiate the various activities with startActivityForResult(), and have the LC "quit" send back a result which tells the parent activity to finish(). That activity could then send the same result as part of its onDestroy(), which would cascade back to the main activity and result in no running activities, which should cause the app to close. But this is fighting the basic design of the Android OS and might break with a future OS upgrade.


Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net

-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf Of Sannyasin Brahmanathaswami via use-livecode
Sent: Thursday, June 07, 2018 12:26 PM
To: How to use LiveCode
Cc: Sannyasin Brahmanathaswami
Subject: Re: Android won't quit

Argh.  I thought I solved in this in my app. But LO... it appears to quit... but is actually not quitting... it leaves  a "corrupt" stack on the phone (android) and when you try to restart it, it opens to splash screen stack, but no messages are firing.  It is "stuck" ; does not appear to user as "crashed" ; but on is dead-on-arrival - just the card 1 of the launcher stack app, with logo.

Good think you caught this. I will have to let users on android force stop, as the only choice.

BR 

J. Landman Gay 

    I want to wipe the app completely so that on next launch I can 
    reinitialize everything.
    
    

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list