I want to check whether the email id entered by user is unique or not so for that initially I have my variable Boolean valid = false;
. On clicking a button i am taking the email id entered and checking it for valid email id expression using regular expression and then i am using an asyntask to check its uniqueness. Code in my onclicklistner is
if (emailid.matches(regexp) && emailid.length() > 0) { new Validate().execute(); Toast.makeText(getApplicationContext(), valid.toString(), Toast.LENGTH_LONG).show(); if (valid) { Intent i = new Intent(getApplicationContext(), GamesFragment.class); startActivity(i); } else { Toast.makeText(getApplicationContext(), "Email Address Already Exist", Toast.LENGTH_LONG).show(); } } else { Toast.makeText(getApplicationContext(), "Check Your Email Address", Toast.LENGTH_LONG).show(); }
Here what problem i am facing is, for first time when i am entering an email which is unique and clicks the button, the Validate()
asynctask checks and sets the valid
variable to true, but it doesn't goes to next activity GamesFragment
because i have declared valid = false
initially. Now when i again click the button, then it goes to next activity as the valid
variable is set to true because of previous click.
Please help i am not getting why this is happening.
Aucun commentaire:
Enregistrer un commentaire