This is because they create an anonymous class for EventListener.
public void onResume() {
super.onResume();
SomeObject object = new SomeObject();
object.setSuccessListener(new EventListener<Boolean>() {
public void onEvent(Boolean response) {
Log.d(TAG_NAME, "Valid response? "+response);
}
});
SomeObjectManager.getSingleton().addObject(object);
}
He explicitly stated that this is done in onResume ().
Anonymous classes (as well as non-static inner classes) have an implicit reference to the surrounding class. Therefore, in this case, the EventListener has a link to the Activity itself.
Therefore, SomeObject has a reference to Activity, because it has a reference to the Anonymous class, which implements EventListener.
, :
, : weve , , -. , ...
, SomeObjectManager, , SomeObject, SomeObject EventListener, , , Activity.
, :
(, , , ), end, SomeObject ( ). SomeObject, .
, SomeObject EventListener.
?