DEBUG/SntpClient(70): request time failed: java.net.SocketException: Address family not supported by protocol on Android -
i create code this:
try { int ct_id; string ct_name; try{ httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://10.0.2.2/update.php"); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); }catch(exception e){ log.e("log_tag", "error in http connection"+e.tostring()); } //convert response string try{ bufferedreader reader = new bufferedreader(new inputstreamreader(is,"iso-8859-1"),8); sb = new stringbuilder(); sb.append(reader.readline() + "\n"); string line="0"; while ((line = reader.readline()) != null) { sb.append(line + "\n"); } is.close(); result=sb.tostring(); }catch(exception e){ log.e("log_tag", "error converting result "+e.tostring()); } //paring data int max = 0; try{ jarray = new jsonarray(result); jsonobject json_data=null; for(int i=0;i<jarray.length();i++){ json_data = jarray.getjsonobject(i); ct_id=json_data.getint("max(id)"); ct_name=json_data.getstring("date"); max = ct_id; } } catch(jsonexception e1){ } catch (parseexception e1) { e1.printstacktrace(); } but when debug appeared:
07-03 08:50:42.657: debug/sntpclient(70): request time failed: java.net.socketexception: address family not supported protocol what mean? , how solve it?
this looks local url , sure apache running on port 80? can try accessing url http://10.0.2.2/update.php in desktop browser , u see things properly. error comes if socket not able establish connection server.
Comments
Post a Comment