Connect to localhost from android device

淺唱寂寞╮ 提交于 2019-12-01 14:16:40

You need to set uses-permission - android.permission.INTERNET in AndroidManifest.xml and also test that (http://192.168.43.17:50473/Service1.asmx) url on web-browser.

Mahesh

Use Http Connection

HttpClient httpclient = new DefaultHttpClient();            
HttpGet httppost = new HttpGet("http://localhost/");
HttpResponse response = httpclient.execute(httppost);              
HttpEntity ent=response.getEntity();
InputStream is=ent.getContent();
einnocent

You may have your web server listening on your loopback interface and not on your network interface. Major signs of this are:

  • Hits on 127.0.0.1 and localhost (from localhost or Android emulator) work
  • Hits on 192.168.xxx.xxx do not work, whether from localhost, LAN, or WAN

I talk more about diagnosing this and fixing this in an answer here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!