Code example for WeakReference

0
  private final WeakReference<HistoryManager> historyManagerRef;
  private final List<Spannable> newContents;
  private final List<String[]> newHistories;
 
  SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
    textViewRef = new WeakReference<TextView>(textView);
    historyManagerRef = new WeakReference<HistoryManager>(historyManager);
    newContents = new ArrayList<Spannable>();
    newHistories = new ArrayList<String[]>();
  } 
 
  @Override 
  public final Object doInBackground(Object... args) {
    try { 
      retrieveSupplementalInfo(); 
    } catch (IOException e) {
      Log.w(TAG, e);
    } 
    return null; 
  }