开发者

How do you access a local port 8080 url from an android http get

I have a restful web service located开发者_如何学编程 on a local tomcat instance.

I'm trying to access the url via a get in my application but am getting the error: host is unresolved

I try to access this url from my android emulator browser to confirm the connection there and am unable to get to it their either. An alert comes up on the screen that says: "an sd card is required to download 125562.bin"

I am not using localhost in my url but something that looks like:

http://192.168.1.2:8080/service/0/12345

It returns straight json

Does anyone know why I can't access this in the android emulator? I can successfully hit this same address from my computer browser as well as iPhone and it brings back json.

Does android handle other ports differently than standard port 80? Is the problem this url doesn't have an extension?


The Android-Emulator has a virtual router, which cut's the Emulators network from the host-computers network.

However, this router is part of the network, too and enables you to access servers running on the local machine by using the IP 10.0.2.2.

So you would use:

http://10.0.2.2:8080/service/0/12345


You need to use 10.0.2.2 to emulate your local machine's 'localhost'.

See Emulator Networking

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜