我有这段代码,据推测,当用户输入正确的密码和正确的电子邮件时,我的应用程序会转到主要 Activity ,尽管当我使用 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();
}
}
最佳答案
这是因为您的方法中的代码不正确。看看下面的代码:
@Override
protected void onPostExecute(final Boolean success) {
...
if (success) {
public void run() {
...
}
finish();
} else {
...
}
}
您有一个名为 run()
的方法 block 是不正确的。所以,你需要删除它。那么你的代码应该是这样的:
@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();
}
}
关于java - 从未使用过的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54848239/