public static AddEmailDialogFragment newInstance(Messenger messenger) { AddEmailDialogFragment frag = new AddEmailDialogFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_MESSENGER, messenger); frag.setArguments(args); return frag; }
/** Displays a dialog fragment for the user to input a valid email. */ private void addEmail() { Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { if (message.what == AddEmailDialogFragment.MESSAGE_OKAY) { Bundle data = message.getData(); String email = data.getString(AddEmailDialogFragment.MESSAGE_DATA_EMAIL); if (checkEmail(email, true)) { // add new user id mEmailAdapter.add(email); } } } }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(returnHandler); AddEmailDialogFragment addEmailDialog = AddEmailDialogFragment.newInstance(messenger); addEmailDialog.show(getActivity().getSupportFragmentManager(), "addEmailDialog"); }