Logcat
java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText ()' on a null object reference at com.paivadeveloper.megamessenger.RegisterActivity $ 1.onClick (RegisterActivity.java:49) at android.view.View.performClick (View.java:6261) at android.widget.TextView.performClick (TextView.java:11159) at android.view.View $ PerformClick.run (View.java:23748) at android.os.Handler.handleCallback (Handler.java:751) at android.os.Handler.dispatchMessage (Handler.java:95) at android.os.Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6776) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386)
Java
public class RegisterActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
private TextInputLayout mDisplayName;
private TextInputLayout mEmail;
private TextInputLayout mPassword;
private Button mCreateBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
mAuth = FirebaseAuth.getInstance();
mDisplayName = (TextInputLayout) findViewById(R.id.reg_display_name);
mEmail = (TextInputLayout) findViewById(R.id.reg_email);
mPassword = (TextInputLayout) findViewById(R.id.reg_password);
mCreateBtn = (Button) findViewById(R.id.reg_create_btn);
mCreateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String display_name = mDisplayName.getEditText().getText().toString();
String email = mEmail.getEditText().getText().toString();
String password = mPassword.getEditText().getText().toString();
register_user(display_name, email, password);
}
});
}
private void register_user(String display_name, String email, String password) {
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
startActivity(mainIntent);
finish();
} else {
Toast.makeText(RegisterActivity.this, "Erro , contate-nos", Toast.LENGTH_LONG).show();
}
}
});
}
}
Thank you