Reputation: 321
i want to register on click register button then after new user is registered it goes back to login screen. for that i am using
@Override
public void onClick(View v) {
username = eusername.getText().toString();
email = eemail.getText().toString();
mobile = emobile.getText().toString();
password = epassword.getText().toString();
registerViews();
if(Validations.hasNoChars(username) && Validations.isEmail(email) && Validations.isMobileNumber(mobile) && Validations.isNotEmpty(password))
{
new CreateUser().execute();
Toast.makeText(RegisterActivity.this, "User Registered", Toast.LENGTH_LONG).show();
//RegisterActivity.this.finish();
}
else{
Toast.makeText(RegisterActivity.this, "Fields are empty", Toast.LENGTH_LONG).show();
}
finish();
}
by this is switched to login screen but application closes. i don't know what I did wrong.
Upvotes: 0
Views: 777
Reputation: 5261
There is no need to start login activity again. You must be finishing your login activity when starting the registration activity. Don't use finish() method while starting registration activity.
Upvotes: 0
Reputation: 176
if(Validations.hasNoChars(username) && Validations.isEmail(email) && Validations.isMobileNumber(mobile) && Validations.isNotEmpty(password))
{
new CreateUser().execute();
Toast.makeText(RegisterActivity.this, "User Registered", Toast.LENGTH_LONG).show();
Intent it=new Intent(this,login.class);
startActivity(it);
}
Try to do this is your Async executes successfully it will transfer you to login activity.
Upvotes: 1