gpt4 book ai didi

android - 进度条运行时异常

转载 作者:行者123 更新时间:2023-11-30 03:20:37 26 4
gpt4 key购买 nike

if (Commons.HaveNetworkConnection()) {
if ((txt_USERNAME.getText().toString().trim() != null && txt_USERNAME
.getText().toString().length() != 0)// username
// check
&& (txt_PASSWORD.getText().toString().trim() != null && txt_PASSWORD
.getText().toString().length() != 0)) {// password
// check
pd = ProgressDialog.show(LoginActivity.this.getApplicationContext(), "","Please wait...");
Toast.makeText(getContext(), "data"+txt_USERNAME + txt_PASSWORD, Toast.LENGTH_LONG).show();
Thread thread = new Thread(LoginActivity.this);
thread.start();

} else {
Toast.makeText(getBaseContext(),
"Invalid username or password",
Toast.LENGTH_LONG).show();
}
} else {
Commons.setOnlineAlert();
}

}catch(Exception e){Toast.makeText(getBaseContext(),"problem in onclick 1 block"+e,Toast.LENGTH_LONG).show();}
}

private Context getContext() {
// TODO Auto-generated method stub
return null;
}

});

当我点击登录按钮时发生运行时异常

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 

请帮我解决这个问题

最佳答案

您正在显示带有 null.. 的 toast 消息 删除此方法

 private Context getContext() {
// TODO Auto-generated method stub
return null;
}

在这一行

Toast.makeText(getContext(), "data"+txt_USERNAME + txt_PASSWORD, Toast.LENGTH_LONG).show();

改为

Toast.makeText(getApplicationContext(), "data"+txt_USERNAME + txt_PASSWORD, Toast.LENGTH_LONG).show();

关于android - 进度条运行时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19218099/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com