Android は設計上、メイン スレッドでのネットワークを許可していませんが、強制することはできますが、良い習慣ではありません。したがって、ユーザー認証のためにデータベースから応答を取得できるように、メイン スレッドと他の 1 つのスレッドを同期させたいと考えています。同期が機能していません..
これはメインスレッドのコードです..
if (loginBTN.getId() == ((Button) v).getId()) {
    String emailId = loginField.getText().toString().trim();
    String password = passwordField.getText().toString().trim();
    postParameters.add(new BasicNameValuePair("username", emailId));
    postParameters.add(new BasicNameValuePair("password", password));
    try {
        System.out.println("b4 response" + responseToString);
        checkLogin();
        System.out.println("after response" + responseToString);
        synchronized (this) {
            while (isAvailable == false) {
                wait();
            }
            if (responseToString.equalsIgnoreCase("1")) {
                statusLBL.setText("Login Successful...");
            }
            else {
                statusLBL.setText("Sorry Incorrect Username or Password...");
            }
        }
    }
    catch (Exception e) {
        statusLBL.setText(e.toString());
    }
}
private void checkLogin() {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    HttpClient http = new DefaultHttpClient();
                    HttpPost request = new HttpPost("http://example.org/api/android_gradhub/login_user.php");
                    UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
                    request.setEntity(formEntity);
                    HttpResponse response = http.execute(request);
                    HttpEntity entity = response.getEntity();
                    // responseToString = EntityUtils.toString(entity);
                    synchronized (this) {
                        while (isAvailable == true) {
                            wait();
                        }
                        responseToString = EntityUtils.toString(entity);
                        notifyAll();
                    }
                    System.out.println("response " + responseToString);
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
    }