I'm trying to create an application where there is a need of uploading images from my mobile. In this case, when I open my Gallery and choose a image and come back to my application, onCreate() is called again due to which the TextView, EditText and the booleans which I've used earlier are cleared.
I don't want this to happen, I want all the values to remain same and when I come back from Device Gallery to my own application. Can you please help me solving this issue?
In this case, when I open my Gallery and choose a image and come back to my application, onCreate() is called again due to which the TextView, EditText and the booleans which I've used earlier are cleared.
Presumably, your process was terminated while your app was not in the foreground. This happens quite a bit in Android. While it is a bit unusual for it to happen when launching a gallery-style app, it is not out of the question, particularly on devices with limited RAM.
Activities will be destroyed and re-created in other situations as well, such as the default behavior on a configuration change (e.g., rotating the screen, changing the language, putting the device into a dedicated car dock).
Use onSaveInstanceState()
to save state information for these sorts of short-term scenarios.