Code example for WeakReference

Methods: clear

0
		public void attach(CommentActivity a) {
			ref = new WeakReference<CommentActivity>(a);
		} 
 
		public void detach() { 
			ref.clear();
		} 
	} 
 
	private static class PostCommentTask  
		extends AsyncTask<Void, Comment, Boolean> 
			implements IAsyncTask<CommentActivity> { 
 
		private static final String TAG = "[AsyncTask].PostCommentTask";
		private WeakReference<CommentActivity> ref;
		private int userId;
		private int activityId;
		private String comment;
 
		public PostCommentTask(CommentActivity a, int userId, int activityId, String comment) {
			this.userId = userId;