'My Register activity is not running. The Text view link on the log in page takes me back to the main activity instead of the log in page.Please advice
The Text view link on the log in page takes me back to the main activity instead of the log in page.What could be the problem? I already put the Reigister Activity in the Launcher This is my Manifest
<activity android:name=".Login"/>
<activity android:name=".Register"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
Login.java
mLoginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String email = mEmail.getText().toString().trim();
String password = mPassword.getText().toString().trim();
if(TextUtils.isEmpty(email)){
mEmail.setError("Email is Required.");
return;
}
if(TextUtils.isEmpty(password)){
mPassword.setError("Enter password");
return;
}
if(password.length()< 6){
mPassword.setError("Password must be more than 6 characters");
return;
}
// Authenticate the user
fAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener((task) -> {
if (task.isSuccessful()) {
Toast.makeText(Login.this, "Logged in successfully", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
} else {
Toast.makeText(Login.this, "Error!" + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
});
mCreateBtn.setOnClickListener(view -> startActivity(new Intent(getApplicationContext(), Register.class)));
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
