Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void logIn(View v){
- boolean validationError = false;
- String username = username_text.getText().toString();
- String password = password_text.getText().toString();
- if(isEmpty(username_text)){
- validationError=true;
- Toast toast = Toast.makeText(getApplicationContext(),"Enter your username",Toast.LENGTH_SHORT);
- toast.show();
- }
- if(isEmpty(password_text)){
- validationError=true;
- Toast toast = Toast.makeText(getApplicationContext(),"Enter your password",Toast.LENGTH_SHORT);
- toast.show();
- }
- if(!validationError){
- /**
- * Log In User:
- */
- Backendless.UserService.login(username, password, new AsyncCallback<BackendlessUser>() {
- @Override
- public void handleResponse(BackendlessUser response) {
- Intent intent = new Intent(MainActivity.this, LoadingActivity.class);
- startActivity(intent);
- }
- @Override
- public void handleFault(BackendlessFault fault) {
- if(fault.getCode().equals("3003")){
- Toast toast = Toast.makeText(getApplicationContext(),"Password does not match username",Toast.LENGTH_SHORT);
- toast.show();
- }else if(fault.getCode().equals("3087")){
- Toast toast = Toast.makeText(getApplicationContext(),"This account still awaits confirmation. Check your email inbox",Toast.LENGTH_SHORT);
- toast.show();
- }
- else{
- System.out.println("ERROR ON LOGIN" + fault.getCode() + " " + fault.getMessage());
- }
- }
- },true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement