开发者

emulator networking

From my android code I try with the android browser to access a tomcat service running on my computer like this :

 Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://localhost:8080/615734.apk"));
 startActivity(myIntent);

Unfortunately all I get is "page una开发者_JAVA技巧vailable" . What should I do to be able to have this running ?


If you really want the host your emulator is running on. Use

10.0.2.2

according to

http://developer.android.com/guide/appendix/faq/commontasks.html#localhostalias


"localhost" may either not be supported on Android or may refer to the device itself. I'm not sure. Anyway it doesn't surprise me it doesn't work.

Work out the LAN IP of your workstation (192.168.0.something probably) and replace "localhost" with this.


Localhost would refer to the android device, not the machine the emulator is running on.


The localhost alias for the Android Emulator is the following IP Address : 10.0.2.2

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜