I was studying this article, Avoid Memory Leaks. There are few suggestions to avoid memory leaks, one of them is below:
Avoid non-static inner classes in an activity if you don't control their life cycle, use a static inner class and make a weak reference to the activity inside. The solution to this issue is to use a static inner class with a WeakReference to the outer class, as done in ViewRoot and its W inner class for instance
1- Can some one elaborate this by giving an example?
2- How to use to static inner classes with Weak-reference to the inner classes?
3- what are the best practices to use that static class in your application to Avoid Memory leaks.
Great thanks.