简体   繁体   English

从未使用的变量

[英]Variable that is never used

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.我有这段代码,我的应用程序,据说,当用户插入正确的密码和正确的电子邮件时,会转到主要活动,尽管当我使用run方法时,它表示从未使用过该变量。

@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();
    }
}

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.您有一个名为run()的方法块,这是不正确的。 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();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM