I was trying to connect to the Authentication in the firebase using email and password but everytime I enter email and password I get registration failed. Here's my code :
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button buttonRegsiter;
private EditText editTextEmail;
private EditText editTextPassword;
private ProgressDialog progressDialog;
private FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.print("In main");
progressDialog = new ProgressDialog(this);
firebaseAuth = FirebaseAuth.getInstance();
buttonRegsiter = (Button) findViewById(R.id.registerUserButton);
editTextEmail = (EditText) findViewById(R.id.editTextEmail);
editTextPassword = (EditText) findViewById(R.id.editTextpassword);
buttonRegsiter.setOnClickListener(this);
}
private void registerUser(){
String email = editTextEmail.getText().toString().trim();
String password = editTextPassword.getText().toString().trim();
if(TextUtils.isEmpty(email)){
//email field is empty
Toast.makeText(this,"Please enter email",Toast.LENGTH_LONG).show();
return;
}
if(TextUtils.isEmpty(password)){
//password is empty
Toast.makeText(this,"Please enter your password",Toast.LENGTH_LONG).show();
return;
}
//if validations are ok
//show a progressbar
progressDialog.setMessage("Registering user...");
progressDialog.show();
firebaseAuth.createUserWithEmailAndPassword(email,password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task){
if(task.isSuccessful()){
Toast.makeText(MainActivity.this,"Registration successful",Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(MainActivity.this,"Failed to register. Please try again", Toast.LENGTH_LONG).show();
}
progressDialog.dismiss();
}});
}
@Override
public void onClick(View view) {
if(view == buttonRegsiter){
registerUser();
}
}
}
Can you let me know what is the error in my code?
This is the error I am getting on logcat
01-03 23:32:49.811 1570-1620/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg