Issue
I subclass of Application
object in my application and I was quite convinced that it will stay alive as long as any application component (Activity
but also Service
) is in use. But I am now observing situation where I see my Service
to be running all the time, but when I try to get to the app (Service
posts ongoing notification which when tapped redirects to app Activity
), the Application
object is being created again (its onCreate()
). This usually happens when app is not used for long time (so its all activities are not used, but still Service
stays running). So my question here is: do I miss something elementary related to Application object or its lifecycle I am unable to spot in docs?
EDIT: when app is "idle" in means user is not using it, but if there's service posted in means some tasks are being executed, incl. posting device location to web service. The device is not short on memory to justify running app killing and from what I observed it only happens if there's no user interaction for some (long enough to make debugging of this quite PITA) time.
Solution
So my question here is: do I miss something elementary related to Application object or its lifecycle I am unable to spot in docs?
No, but your process was restarted along the way. The Application
object is never discarded, except when the entire process is terminated.
The device is not short on memory to justify running app killing
Android has its own algorithm for determining how long to keep a service-bearing process around. The process will not live indefinitely. What you consider to be "justified" is not taken into account by the OS.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.