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

Help with login screen!

I have been following the build a self destructing messaging app tutorial. I recently switched to Backendless instead of using Parse. I keep getting an error code: 3003. (Invalid Login or password). It gives me this message no matter what I input into the editTexts. Here is my code:

import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;

import com.backendless.Backendless; import com.backendless.BackendlessUser; import com.backendless.async.callback.AsyncCallback; import com.backendless.exceptions.BackendlessFault; import com.jordanpeterson.textly.R; import com.jordanpeterson.textly.utils.Constants;

public class LoginActivity extends AppCompatActivity { protected EditText mUsername; protected EditText mPassword; protected TextView mSignUpTextView; protected Button mLoginButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Backendless.initApp(this, Constants.APPLICATION_ID, Constants.ANDROID_SECRET_KEY, Constants.VERSION);

    mUsername = (EditText) findViewById(R.id.usernameLoginField);
    mPassword = (EditText) findViewById(R.id.passwordLoginField);
    mSignUpTextView = (TextView) findViewById(R.id.signUpTextView);
    mSignUpTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent loginIntent = new Intent(LoginActivity.this, SignUpActivity.class);
            startActivity(loginIntent);
        }
    });
    mLoginButton = (Button) findViewById(R.id.loginButton);
    mLoginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = mUsername.getText().toString();
            String password = mPassword.getText().toString();

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

            if (username.isEmpty() || password.isEmpty()) {
                AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                builder.setMessage(R.string.login_error_message)
                        .setTitle(R.string.login_error_title)
                        .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
            } else {

                Backendless.UserService.login(username, password, new AsyncCallback<BackendlessUser>() {
                    @Override
                    public void handleResponse(BackendlessUser backendlessUser) {
                        Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        startActivity(intent);
                    }


                    public void handleFault(BackendlessFault fault) {
                        // an error has occurred, the error code can be retrieved with fault.getCode()
                        AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                        builder.setMessage(fault.getCode())
                                .setTitle(R.string.error_title)
                                .setPositiveButton(android.R.string.ok, null);
                        AlertDialog dialog = builder.create();
                        dialog.show();
                    }
                });

            }
        }
    });


}

}

Thanks, Jordan