Reputation: 721
I am using a JobIntent service to perform some operation. I am starting the Service from say Screen A.
After the service performs its work I am sending a callback from JobIntent Service to the Screen A. Then immediately the Screen A finishes itself and opens a new Screen say B.
I am able to notice that there is a log stating Leaked Service Connection. Below is the log
android.app.ServiceConnectionLeaked: Activity Package.ScreenA has leaked
ServiceConnection Package.ServiceName$1@7a41f83 that was originally bound here
What does this error mean and is there any damage if this error continues? What can be done to prevent these kinds of errors?
Even though I am not sure but the service holds the context reference of the screenA which is why this might be happening?
Thanks in Advance!
Upvotes: 0
Views: 627
Reputation: 614
@Rahulrr2602 Please use this chart to understand the limitations of each.
Upvotes: 1
Reputation: 614
Watch out for JobIntentService memory leak
Pass activity.getApplicationContext() — then static map indirectly will hold only Application object instance reference.
You can read this post this would be helpful for you.
https://medium.com/@luszczuk/watch-out-for-jobintentservice-memory-leak-828a629ab085
Credit: Michał Łuszczuk
Upvotes: 2