模拟器网络

时间:2010-04-15 07:52:16

标签: android

从我的android代码中我尝试使用android浏览器访问在我的计算机上运行的tomcat服务,如下所示:

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

不幸的是,我得到的是“页面不可用”。我该怎么做才能让它运行?

4 个答案:

答案 0 :(得分:2)

如果您真的想要运行模拟器的主机。使用

10.0.2.2

根据

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

答案 1 :(得分:1)

Android上可能不支持“localhost”,也可能是指设备本身。我不确定。无论如何,它不会让我感到惊讶它不起作用。

计算工作站的LAN IP(可能是192.168.0.something)并用此替换“localhost”。

答案 2 :(得分:0)

Localhost会引用android设备,而不是运行模拟器的机器。

答案 3 :(得分:0)

Android模拟器的localhost别名是以下IP地址:10.0.2.2