This is how I have organized my data:
- I've created an Application class in my Android project
- In the Application Class I have an ArrayList Of Objects
- In the other Activities I call some methods of Application Class that return to me a portion of the aforementioned list
Now the scenario that puzzles me: In a certain Activity If a button is pressed
- I check if there is an internet connection
- If there isn't one I start an Intent to open Settings for the user to enable mobile networks or WiFi
when It returns though it seem that the application is destroyed because onCreate is called again but at that time the arrayList in my Application class is this time null. So my questions are
- why is my activity destroyed and not just paused ?
- If it is destroyed why my app won't start itself from the beginning but it starts only from the Activity that started Activity Action.Settings?
- If only the latest Activity is Destroyed and not the whole app, how come the data in Application are lost?
this Is how I've declared the ArrayList of objects in my Application class
private static ArrayList<PointOfInterest> pois;
EDIT: I put a Log.i() on onDestroy() of the Activity and it was never printed. But on When I returned from the Settings, onCreate() was called (without onDestroy having been called), how is that possible?