Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Adding Users Using Parse.com Error Messages with Dialogs

How to Add More User signup fields to Rabbit

Hi Mr. Jakuben,

Thanks for this wonderful android tutorial. Pls. I am trying to add more fields to the Rabbit signup (i.e. Phone Number, Address, Age). However after completing and submitting the signup form only the initial fields are sent to the back-end, the data for new fields I added are not captured. Here is my code

protected static final ParseUser user = null;
protected EditText mFullname;
protected EditText mAddress;
protected EditText mState;
protected EditText mPhone;
protected EditText mAge;
protected EditText mUsername;
protected EditText mPassword;
protected EditText mEmail;
protected Button mSignUpButton;

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_sign_up);

    mFullname = (EditText)findViewById(R.id.fullname);
    mAddress = (EditText)findViewById(R.id.address);
    mState = (EditText)findViewById(R.id.state);
    mPhone = (EditText)findViewById(R.id.phonenumber);
    mAge = (EditText)findViewById(R.id.age);
    mUsername = (EditText)findViewById(R.id.usernameField);
    mPassword = (EditText)findViewById(R.id.passwordField);
    mEmail = (EditText)findViewById(R.id.emailField);
    mSignUpButton = (Button)findViewById(R.id.signupButton);
    mSignUpButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            String username = mUsername.getText().toString();
            String password = mPassword.getText().toString();
            String phonenumber = mPhone.getText().toString();
            String email = mEmail.getText().toString();

            username = username.trim();
            password = password.trim();
            phonenumber = phonenumber.trim();
            email = email.trim();

            if (username.isEmpty() || password.isEmpty() || phonenumber.isEmpty() || email.isEmpty()) {
                AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
                builder.setMessage(R.string.signup_error_message)
                    .setTitle(R.string.signup_error_title)
                    .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
            }
            else {
                // create the new user!
                setProgressBarIndeterminateVisibility(true);

                ParseUser newUser = new ParseUser();
                newUser.setUsername(username);
                newUser.setPassword(password);
                newUser.setEmail(email);

                user.put("fullname", "fullname");
                user.put("address", "address");
                user.put("state", "state");
                user.put("age", "age");
                user.put("phonenumber", "phonenumber");

I followed an example from Parse.com on how to add additional fields, but it doesn't seem to solve my problem.

1 Answer

It seems you are mixing up several variables and keys especially in the "else" area. I also wonder why you made this...

protected static final ParseUser user = null;

That makes the variable "user" to be treated as a constant and it remains null forever. I am not sure if that is what you really want to do, since it is not a key. Also using it in your else statement mixes up 2 different users "newUser" and "user". You can read more on Final Variables here.

Try checking this out, I believe it would help you understand what went wrong.

Hi Gloria,

Thanks, I'll check it out.

You are welcome