AnsweredAssumed Answered

No MapView.removeOnTouchListener? Causes memory leak.

Question asked by Crittermap on Nov 12, 2018

How are we supposed to remove the onTouchListener when our Activity gets destroyed?


There is a setOnTouchlistener but no remove.


Setting it to null won't work - you will throw an exception.


This is important because you are holding on to the reference and our activity can't be garbage collected, causing a huge memory leak.


We have used removeListeners for Scale and NavigationChanged.


The only thing I can think of now is to create a DummyonTouchListener that does nothing, and set it in onDestroy.