I have this non-static inner class that causes a memory leak because it contains an implicit reference to the wrapper class:
private class CalendarScheduleUpdatedEventListener extends ScheduleUpdatedEventListener.Stub { @Override public void onScheduleUpdatedEvent() throws RemoteException { updateCalendar(); } }
To prevent it from leaking, I need to make it static:
private static class CalendarScheduleUpdatedEventListener extends ScheduleUpdatedEventListener.Stub { @Override public void onScheduleUpdatedEvent() throws RemoteException { updateCalendar();-> Compiler error - trying to access a non-static... } }
It is not possible to make updateCalendar() static, because in it I get access to other non-static variables, and this becomes a mess. What should I do?
source share