0

I saw many place using WeakReference like below, what's the reason to use like this? Is it must to be use like that in this senario?

public class MyActivity extends Actiivity {

 private class InitServiceRunnable implements Runnable
    {
        WeakReference<MyActivity> mActivityRef;
        public InitServiceRunnable(MyActivity activity)
        {
            mActivityRef = new WeakReference<MyActivity>(activity);
        }

        @Override
        public void run() { /* using mActivityRef here */}
    }

}
gladman
  • 1,180
  • 3
  • 15
  • 38

0 Answers0