Android Question Map in Process Globals is erased

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings, all.

Thank you for taking out of your time to read this question and hopefully to unravel this mystery.

My test environment consists of:

Nexus 7 - Android 4.3 Geekbench 900+
Samsung S3 - Android 4.1 - Geekbench 900+
Toshiba Excite
LG Optimus - Android 2.3 - Geekbench 504
Visual Land 10 - Android 4.0 (older tablet made in China) Geekbench 350 - not Google certified.
RAM is 1GB and I am able to run Kingston Office (50MB) in it.

My app, 21MB 5K lines of code, has 7 activities and 2 code modules.

I ran into the strangest problem in the Visual Land test environment. A map is wiped out from one activity returning to the Main Activity.

1. Map is declared in Process Globals in Main
2. Map is initialized in a sub in one of the code modules called by Main upon start up. The code module clears and fills the map with 66 entries.
3. In running the app, and following the logs with entries made by me:
a. In Main Activity Resume the size of the map is 66.
b. User initiates Activity A by selecting menu
c. User returns to Main via menu. Activity A issues Activity Finish.
d. Activity A Activity Pause shows size of map as 66 just before it returns to Main.
e. In Main, Activity Resume shows size of map as 0. The entries are erased from the Map.

The map is initialized and cleared ONLY once in the code module called by Main upon start up.

The app runs perfectly in all other devices.

Any ideas????

Thanks again!

Addendum
I just realized from the logs that when Activity A returns to Main, the activity Main is destroyed and Activity Create is called with isFirst = False. None of the other devices behave in that fashion. In the other devices, the normal activities life cycle is followed - Activity Resume in Main follows Activity A Pause when uses exits Activity A.
Now, I know what is making it go wrong. I do not know why? It would be as if a device orientation took place without alerting the app. I am beginning to think it may be a hardware failure, but this is a guess.
 
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Erel.

I thought Android preserved the activity while the process was running. I thought the activity would be destroyed upon device orientation change (which I capture), app issuing Activity.Finish or user terminating the process by "swiping off" the app or turning the device off.

I have several large maps which I both initialize and load from Direct Assets files in the app on Activity Create in Main. I initialize and load them if FirstTime=True. I will have to modify my code to load the maps in Activity Create in Main regardless of FirstTime status.

I find it conflicting that Android destroys the activity and the Process Globals but still knows that the maps were initialized. I want to understand the rules and follow them since I want to play in the Android sandbox even if the rules, for now, do not make logical sense to me (eventually they will).

Would it make a difference if the maps were defined in the Process Globals of the code modules? Can the code modules and its Process Globals be destroyed while the process is running?

Very best regards.

Sandy
 
Upvote 0
Top