0

用户名和密码正确但 isResponse() 方法返回 false

请帮助我我们的代码是否正确?

           public boolean isUserAvailable() {
    // Create a new HttpClient and Post Header
    try {
    HttpClient httpclient = new DefaultHttpClient();

    HttpPost httppost = new HttpPost(Commons.IS_USER_AVAILABLE_NEW_REGISTRATION_LINK
                    + edit_USERNAME.getText().toString().trim());


        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();

        if ("available".equalsIgnoreCase(EntityUtils.toString(resEntity))) {
            return true;
        }
    } catch (ClientProtocolException e) {
        Toast.makeText(getApplicationContext(), "error"+e, Toast.LENGTH_LONG).show();

    } catch (IOException e) {
        Toast.makeText(getApplicationContext(), "error"+e, Toast.LENGTH_LONG).show();

    }
    return false;

}
4

0 回答 0