Code example for WeakReference

Methods: clear

		public void attach(CommentActivity a) {
			ref = new WeakReference<CommentActivity>(a);
		public void detach() { 
	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) {
Connect your IDE to all the code out there  Get Codota for Java