with modulglobal values (user-inputs)
Speaking about module is a bit confusing in this context. A class variable only exists during the life time of that one class and that a module variable exists during the life time of a program and can be mutated by all classes? So where you define a global makes a lot of difference.
The program demonstrate the life time of variables in the main module, the classes, and module code. By-The_Way I don't understand why you wants to terminate and reload a activity. Not bothered by your reasons, I choose a different approach. The difference between use and abuse is very thin. I'm going to use / abuse the lifetime of a class variable because we have full control over the lifetime of a class object. Combined with smart shifting of the values between the activities produces the following result.
The program use a global variables in a code module, load it in the main module during start-up where you can update it. I take a start text only for demonstration
purposes, be free to start with a empty text string or what ever you want.
When you start Activity1 it take this global value from the code module, then you can update the value during the life time of Activity1. Reload of Activity1 is simple re-initialize and update the input filed with the value of the global code module value.
From Activity1 you can start Activity2 which also take the global code module as the default text field input with each (re)load). In Activity2 you can also update the value of the global text string variable. Again the start value is the value of the global code module value.
I show you how simple you can make a fault. Because the main process is still in the background, the global code text value is not updated from Activity2. So if you close Activity2 and return to main process, the original value is still displayed on the screen. However if you start Activity1 from the main activity, then the updated text value from Activity2 is showed in Activity1 because there is now update of the text field in the resume sub defined in the main activity. Off course you can build an update mechanism when the global code module text string is changed.
In a have loaded Android environment less imported processes can be killed. As far as I correctly understand, the Starter process will not be killed. So if you put important variables there, they keep always alive.
Is there a way, to get a 'virgin' Activity2 each time I load it?
@
Pflichtfeld I hope for you that how I putting away in the different modules and activities and the way in which they are used will give you a usable 'virgin' reload (sorry I'm just quoting ? )