This is my function to register.
If I get the correct feedback from my server it will change the isCreated to true boolean and move to the next Activity.
The problem is that the boolean cannot be edited, and I need to click the Button again to move to the next Activity (the boolean can only be set to true after I click the Button)?
public void onClick(View view) {
switch(view.getId()){
case R.id.register:
if(!validate())
Toast.makeText(getBaseContext(), "Enter user information!", Toast.LENGTH_LONG).show();
// call AsynTask to perform network operation on separate thread
new HttpAsyncTask().execute(herokuServer);
if (isCreated)startActivity(new Intent(this, Preference.class));
break;
}
private class HttpAsyncTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
newAccount = new userAccount();
newAccount.setPassword(password.getText().toString());
newAccount.setEmail(email.getText().toString());
return POST(urls[0],newAccount);
}
// onPostExecute displays the results of the AsyncTask.
@Override
protected void onPostExecute(String result) {
if (result.equals("Welcome to Opshun!"))isCreated = true;
//if (!result.equals("Welcome to Opshun!")) result = "Please use your email to register!";
Toast.makeText(getBaseContext(), result, Toast.LENGTH_LONG).show();
}
}
Is there any way to fix it?