Question

I've create an Application class of my own.

I try to debug it and the code stops at Application.onCreate() but does not stop at onLowMemory.

To test the scenario I open a lot of other high memory applications.

What I see is that the debug session terminated (in eclipse) and some of my static variables turned to null - indicates the the process has ended.

Not only did the debug NOT stop @ the breakpoint of the method, I've put a Log.e(...) line and don't see it as well.

Any idea of why the method was not invoked?

Thanks.

Was it helpful?

Solution

I don't think that there are any guarantees that this method will ever be called.

From the docs:

While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

Since the point at which it is called is not defined, it could choose to never call it.

In general, Android is free to kill your Application whenever it wants, as long as it is in the background. You should only rely on methods in the lifecycle (like onPause, onStop, onDestroy) that specifically state that they are guaranteed to be called in order to do any necessary cleanup.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top