1

enter image description here

It says: Do not place android context classes in static fields, this is a memory leak.

I know that activity context should not be placed in static fields because it will be kept alive until the app process ends, and if it is passed to other classes using constructor, it will cause other classes to be kept alive as well.

But why ImageView cannot be static(I also found SwipeRefreshLayout cannot be static either)? Is it because ImageView contains a context? No warnings on defining other views like Button,TextView as static.

thank you

drunkpiano
  • 155
  • 1
  • 6

0 Answers0