RhinoCan
Well-Known Member
What is my best way to learn and properly understand the Android life cycle?
I used to develop Java applications for desktop use on Windows and got quite used to putting an Exit button on every program so that the user could leave the program when they are done; that would inevitably cause a System.exit(0) when it was detected. But I learned last night that this is NOT appropriate for the Android environment via a StackOverflow discussion I found: https://stackoverflow.com/questions...android-studio-and-an-application-project-tha
Now, that discussion is focused mostly on pleasing users that expect an Exit button (or menu option) and I largely understand the reasons why this may not be appropriate in Android. But it raises the question of what I'm supposed to do if the app encounters a problem that means it should not proceed? If System.exit(0) or some of the other alternatives proposed in that discussion are off the table, then what SHOULD my app do?
For instance, one possibility that I can easily imagine is a situation where my app, which shows a list of sales, is unable to find any sales on the database. Normally, that shouldn't happen but I can see two situations where it might: the database itself is offline for some reason or the database is online but simply has no data in it (probably because I deleted it for some reason to do with testing and forgot to restore it). In either case, with none of the existing data available, there is none to show the user and the app no longer has much purpose. What SHOULD happen then? If the database is down, I would think I'd want to explain to the user via an AlertDialog that the database is down and the app will be unusable until the database is back up and tell them that the "system administrator" (that's me) has been notified and then have the program send me a text. At that point, I was going to close the app but the discussion I've cited effectively says it's just going to stay around until the memory is needed for something else. Well, if the app is still running, my two users may continue trying to use it and frustrating themselves. Do I just keep popping up that AlertDialog and sending texts to the poor old system administrator?
Also, for the case where the data is simply gone because I deleted it and forgot to restore it (mind you, I don't expect that to happen once I'm finished testing!), do I notify the user but disable the buttons that they normally click on to do things like change or delete sales pending the restoration of the data?
Ultimately though, I suspect that it would be best if I properly understood the Android life cycle in general rather than peppering this forum with questions about specific situations like mine. What's the best way of getting at least the basics of the life cycle?
I used to develop Java applications for desktop use on Windows and got quite used to putting an Exit button on every program so that the user could leave the program when they are done; that would inevitably cause a System.exit(0) when it was detected. But I learned last night that this is NOT appropriate for the Android environment via a StackOverflow discussion I found: https://stackoverflow.com/questions...android-studio-and-an-application-project-tha
Now, that discussion is focused mostly on pleasing users that expect an Exit button (or menu option) and I largely understand the reasons why this may not be appropriate in Android. But it raises the question of what I'm supposed to do if the app encounters a problem that means it should not proceed? If System.exit(0) or some of the other alternatives proposed in that discussion are off the table, then what SHOULD my app do?
For instance, one possibility that I can easily imagine is a situation where my app, which shows a list of sales, is unable to find any sales on the database. Normally, that shouldn't happen but I can see two situations where it might: the database itself is offline for some reason or the database is online but simply has no data in it (probably because I deleted it for some reason to do with testing and forgot to restore it). In either case, with none of the existing data available, there is none to show the user and the app no longer has much purpose. What SHOULD happen then? If the database is down, I would think I'd want to explain to the user via an AlertDialog that the database is down and the app will be unusable until the database is back up and tell them that the "system administrator" (that's me) has been notified and then have the program send me a text. At that point, I was going to close the app but the discussion I've cited effectively says it's just going to stay around until the memory is needed for something else. Well, if the app is still running, my two users may continue trying to use it and frustrating themselves. Do I just keep popping up that AlertDialog and sending texts to the poor old system administrator?
Also, for the case where the data is simply gone because I deleted it and forgot to restore it (mind you, I don't expect that to happen once I'm finished testing!), do I notify the user but disable the buttons that they normally click on to do things like change or delete sales pending the restoration of the data?
Ultimately though, I suspect that it would be best if I properly understood the Android life cycle in general rather than peppering this forum with questions about specific situations like mine. What's the best way of getting at least the basics of the life cycle?