Do we have any kind of a quick guide with tips like this?
The layouts are loaded ONLY in Activity_Create
I'm pretty sure I got that one covered, and I don't have time to look at my code right now, but lately I have been testing my app by leaving it on random activities and then do other stuff on my phone to essentially force Android to start clearing out the clutter. Often times when I return to my app, it complains of lists not being initialized, etc.
These lists are located in other activities and variables are passed back and forth. Most times it isn't a problem, but when I force my phone to bog down and start killing stuff off then return to my app, I get errors like other activities are no longer initialized. To prevent this from crashing my app, I now am checking to see if these lists that I access from other activities are initialized, and if not, I just bail out of the current activity (force the app to close). It isn't elegant, but it is better than receiving errors.
I'm tempted to stay away from multiple activities in the future and just stick with panels. Android seems to kill off activities in my app that contain info that is necessary for my other activities to run correctly. I even added a code module lately and stored stuff in there as opposed to an activity and even that causes me to get lists not initialized errors. I can't make heads of tails out of what Android is keeping and what it is killing off. Makes it difficult to write a solid app when the OS seems to fight you every step of the way. :BangHead:
I use global variables in activities and code modules, and from what I am told, the OS will keep them around if they are related to a running activity but I do not see that behavior. It's very frustrating. I start Activity A, then Activity B (which uses lists in Activity A), then hold the home key and do other stuff then return to my app, Activity B has all sorts of errors about lists in Activity A not being initialized. Since I can do so in Activity A, I now have decided to kill off Activity B. Kind of sloppy, but then it returns me to a fully functional Activity A like nothing was ever wrong.
Part of this I blame on my HTC EVO 4G, because they have gotten aggressive with ending old processes in the background. Nice idea but they went way overboard and I have actually seen activities killed killed right before my eyes. Activities in the FOREGROUND! Reading a news story, then blam! The default browser closes out of the blue. Only to back out of that to see every HTC-supplied widget get entirely refreshed.
I've always loved the challenge of programming and Android is a great mobile patform to make apps for but man... sometimes you just want to :BangHead:
I hope I have a valid point here! I've been unable to sleep so am taking some Ambien, but then I jumped on the PC to check on something else and here I am.
