开发者

emulator networking

开发者 https://www.devze.com 2022-12-26 18:06 出处:网络
From my android code I try with the android browser to access a tomcat service running on my computer like this :

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

精彩评论

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