Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable that is never used

Tags:

java

android

I have this block of code where my app, supposedly, when the user inserts a right password and a right email, goes to the main activity, although when I used the run method, it says that the variable is never used.

@Override
protected void onPostExecute(final Boolean success) {
    mAuthTask = null;
    showProgress(false);

    if (success) {
         public void run() {
            startActivity(new Intent(getBaseContext(), Second.class));
            finish();
        }
        finish();
    } else {
        mPasswordView.setError(getString(R.string.error_incorrect_password));
        mPasswordView.requestFocus();
    }
}
like image 524
Tomas Mota Avatar asked Nov 28 '25 03:11

Tomas Mota


1 Answers

It is because you have incorrect code in your method. Take a look at the following code:

@Override
protected void onPostExecute(final Boolean success) {
    ...

    if (success) {
         public void run() {
            ...
        }
        finish();
    } else {
       ...
    }
}

You have a block of method named run() which is incorrect. So, you need to remove it. Your code should be something like this then:

@Override
protected void onPostExecute(final Boolean success) {
    mAuthTask = null;
    showProgress(false);

    if (success) {
        startActivity(new Intent(getBaseContext(), Second.class));
        finish();
    } else {
        mPasswordView.setError(getString(R.string.error_incorrect_password));
        mPasswordView.requestFocus();
    }
}
like image 194
ישו אוהב אותך Avatar answered Nov 29 '25 16:11

ישו אוהב אותך