Android从服务器提供空值

Android从服务器提供空值,android,Android,您好,在我的应用程序中,我向服务器发送请求。在第一次调用时,它会给我null值,然后它会给我值。为什么我会得到null请帮助我。我的代码是.HttpUtilities类包含请求方法 public class WebUtilities { private static HttpClient client = new DefaultHttpClient(); private static HttpGet request; public static String getRequest

您好,在我的应用程序中,我向服务器发送请求。在第一次调用时,它会给我null值,然后它会给我值。为什么我会得到null请帮助我。我的代码是.HttpUtilities类包含请求方法

public class WebUtilities
{
private static HttpClient client = new DefaultHttpClient();     
private static HttpGet    request;
public static String getRequest(String strURL)
{
    String Result = " ";
    request = new HttpGet(strURL);
    try
    {
        HttpResponse response = client.execute(request);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
            Result = new HttpUtilities().request(response);
        else
            Result = null;
    }
    catch (Exception ex)
    {
        Result = null;
    }
    return Result;
}
}
 public String request(HttpResponse response)
{
    try
    {
        InputStream in = response.getEntity().getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuilder str = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null)
        {
            str.append(line);
            str.append("\n");
        }
        in.close();

        result = str.toString();

    }
    catch (Exception ex)
    {
        result = "";
    }
    return result;
}
试用

Result = EntityUtils.toString(response.getEntity()) 
而不是

Result = new HttpUtilities().request(response);