2013-03-22 72 views
2

我正在为客户端是android和服务器是本地服务器的Android客户端服务器应用程序。 它在模拟器上成功运行,但不在设备上运行。它实际上没有崩溃,但给出了从服务器客户端服务器通信应用程序在仿真器上运行,但不在设备上

响应
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> 
    <title>ERROR: The requested URL could not be retrieved</title> 
</head> 
<body> 
    <div id="content"> 

    <h1>ERROR</h1> 
    <h2>The requested URL could not be retrieved</h2> 
    <hr/> 
    <P> 
    While trying to retrieve the URL: 
    <A HREF="http://10.0.2.2/test/testing.php">http://10.0.2.2/test/testing.php</A> 
    <P> 
    The following error was encountered: 
    <UL> 
     <LI> 
      <STRONG> 
     Connection to 10.0.2.2 Failed 
     </STRONG> 
    </UL> 
     <P> 
    The system returned: 
    <PRE><I> (110) Connection timed out</I></PRE> 
     <P> 
     The remote host or network may be down. Please try the request again. 
      <P>Your cache administrator is <A HREF="mailto:webmaster">webmaster</A>. 
    </div> 
      <!-- 
      -- Unfortunately, Microsoft has added a clever new 
      -- feature to Internet Explorer. If the text in 
      -- an errors message is too small, specifically 
      -- less than 512 bytes, Internet Explorer returns 
      -- its own error message. Yes, you can turn that 
      -- off, but *surprise* its pretty tricky to find 
      -- buried as a switch called smart error 
      -- messages That means, of course, that many of 
      -- Resins error messages are censored by default. 
      -- And, of course, youll be shocked to learn that 
      -- IIS always returns error messages that are long 
      -- enough to make Internet Explorer happy. The 
      -- workaround is pretty simple: pad the error 
      -- message with a big comment to push it over the 
      -- five hundred and twelve byte minimum. Of course, 
      -- thats exactly what youre reading right now. 
     //--> 
     </body></html> 

我用我的HttpClient url是10.0.2.2,也使用Internet的权限和USB调试上。我只想在设备上运行。是否有任何设置,我必须在移动设备上更改或在Android项目中更改,如android清单文件或任何想法。

+1

输入http://10.0.2.2/test/testing.php到你的手机浏览器,看看你是否可以到它。您的手机是连接到同一网络还是使用3/4g? – Ryan 2013-03-22 13:08:01

+0

一分钟后没有打开它,它说“数据连接问题..服务器无法通信,稍后再试” – 2013-03-22 13:36:39

+0

防火墙已关闭。仍然会说同样的信息。 – 2013-03-22 13:56:50

回答

0

模拟器可以工作,因为它与计算机位于同一网络中。如果你想在你的手机上使用URL,你将不得不连接到你的服务器的网络。您正在使用本地 IP地址,因此您应该位于同一网络中。这会使用手机的无线连接。

你可以做的另一件事是使用你的外部IP地址,这样你就不需要在同一个网络上。你应该谷歌的具体细节,但我认为你只需要找到你的外部 IP地址(whatismyip.com),并确保您要连接的端口是在路由器的设置(通常是端口80)打开。这可以让你使用手机的3G或4G。

+0

感谢所有回复13v ...... – 2013-03-22 14:21:08

+0

没问题,是这个问题吗? – Ryan 2013-03-22 14:27:19

+0

哈哈....不,我提到过... – 2013-03-25 05:54:36

相关问题