下面是我的代码,它显示了一个进度对话框来验证用户。当用户 ID 或密码不匹配(响应代码不是 200)但我收到警告时,我想显示 Toast 消息
WARN/InputManagerService(58): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy
并且吐司消息不显示
代码
new Thread() {
public void run() {
Looper.prepare();
try {
performBackgroundProcess();
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
}
}.start();
private void performBackgroundProcess() {
String sUserName = usernameEditText.getText().toString();
String sPassword = String authentication = sUserName + ":" + sPassword;
String login = Base64.encodeToString(authentication.getBytes(),
Base64.NO_WRAP);
Resources res = getResources();
String URLLogin = res.getString(R.string.URLlogin);
RestClient client = new RestClient(URLLogin, login);
try {
client.Execute(RequestMethod.POST);
} catch (Exception e) {
e.printStackTrace();
}
if (client.getResponseCode() != 200) {
progressDialog.dismiss();
Toast.makeText(getApplicationContext(),"Username or Password does not match",Toast.LENGTH_SHORT).show();
}
}