 I have been trying for hours to send a POST request to a php which sends back a json response. But that one line of code has been giving me problems and I cannot seem to move forward. I am so frustrated. I have looked up countless examples of others using the same line! but for some reason it won't work for me!
this is my code snippet for my doinBackgrounds:
I have been trying for hours to send a POST request to a php which sends back a json response. But that one line of code has been giving me problems and I cannot seem to move forward. I am so frustrated. I have looked up countless examples of others using the same line! but for some reason it won't work for me!
this is my code snippet for my doinBackgrounds: 
protected Void doInBackground(Void... voids) {
    HttpClient httpClient=new DefaultHttpClient();
    HttpGet request=new HttpGet();
    BufferedReader in=null;
    String data=null;
    HttpResponse response = null;
    try {
        URI website=new URI("login.php");
        request.setURI(website);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    HttpPost httpPost=new HttpPost("login.php");
    List<NameValuePair> nameValuePairs=new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("name", name));
    nameValuePairs.add(new BasicNameValuePair("password", pwd));
    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    try {
        response=httpClient.execute(request);
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        in=new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        String line=in.readLine();
        System.out.println(line);
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (Utility.isNotNull(name) && Utility.isNotNull(pwd)) {
        RequestParams params = new RequestParams();
        if (Utility.validate(name, pwd)) {
            params.put("username", name);
            params.put("password", pwd);
            bloggedIn=true;
            onPostExecute();
        } else {
            loginActivity.InvalidToast();
        }
    } else {
        loginActivity.EmptyToast();
    }
    return null;
}
 
    