Code example for WeakReference

Methods: clear

0
		public void attach(SignupActivity a) {
			ref = new WeakReference<SignupActivity>(a);
		} 
 
		public void detach() { 
			ref.clear();
		} 
	} 
 
 
	@Override 
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case 0 : 
			return  
				new AlertDialog.Builder(this)
					.setIcon(R.drawable.error_circle)
					.setTitle("Error") 
					.setMessage("Passwords do not match.\n Please try again.") 
					.setPositiveButton("OK", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int whichButton) {