I was making a program that uses a PHP page to connect to a database and then parse the information through JSON. The problem is, I get a RuntimeException on the AsyncTask responsible for the network comunications. I am using a physical android device for testing.
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("URL");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("password", "******"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Error appears on this line
HttpResponse response = httpclient.execute(httppost);
//JSON Parsing here
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
catch (Throwable t)
{
CharSequence message = "Request failed: " + t.toString();
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
}