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,208
  • 4
  • 19
  • 39

0 Answers0