I want to send Parameters to PHP page and wait for receive String Respond but it always throws IOException when i pass this
HttpResponse response = httpclient.execute(httppost);
it try to execute both android device and emulator this is my fuction
public String HTTPPostData(String url,String... params) throws IllegalStateException, IOException {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
for (int i=0;i<params.length;i++){
nameValuePairs.add(new BasicNameValuePair("params_" + i, params[i]));
}
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
InputStream is = response.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(20);
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);}
return new String(baf.toByteArray());
}