Slide 24
Slide 24 text
Service service = new Service();
Activity activity = new Activity(service);
activity.onStart();
ReferenceQueue referenceQueue = new ReferenceQueue();
PhantomReference reference = new PhantomReference(service.
listener, referenceQueue);
activity.onStop();
activity = null; // at this point we removed the strong reference to our Activity, service should not leak the
Activity & Activity should be GC'd
Runtime.getRuntime().gc();