下面是我的代碼,它顯示了一個進度對話框來驗證用戶。 我想顯示敬酒消息,當用戶ID或密碼不匹配(響應代碼不是200) 但我得到一個警告吐司消息不顯示,得到警告:窗口已經聚焦,忽略焦點增益:com.android.internal.view
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();
}
}
據我所知,沒有代碼在後臺運行,得到響應後我想顯示烤麪包...無論如何,如果問題可以使用異步任務解決,請你舉例或請編輯我的帖子 – Romi