Issue
I am facing something really strange. In the course of the user using the app, I am creating threads and using locationManager to get location updates.
Now, in cases when the user leaves the app and Android triggers the onDestroy and the user coming back to the app later, I see that the old threads are still running and the locationManager still triggering events. Of course I could stop threads and locationManager in onDestroy (which I certainly should do), but how can it be explained that Android keeps this up and running after it decided to kill the app?
Solution
Leaving the app doesn't mean Android will shutdown all your started threads. In worst case your threads even keep a reference to your activity, making it unable to be garbage collected and finally causing a memory leak (maybe you already experienced that you're in another app and Android shows you "App xy has stopped working"). That's caused by your threads trying to update an actually closed activity.
So correct approach in the end is to close all threads at latest in onDestroy()
yourself.
Answered By - Syex
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.