[英]How can I send http messages from android app( physical device) to my local server without using internet connection?
I have an app that runs in an emulator. 我有一个在模拟器中运行的应用程序。 The app sends multiple messages to my local server, for manipulating data. 该应用程序将多条消息发送到我的本地服务器,以处理数据。 While i was using the app in my emulator i was using: 当我在模拟器中使用该应用程序时,我正在使用:
http://10.0.2.2/path
to reach the server. 到达服务器。 I would like to use a physical device to connect to the server. 我想使用物理设备连接到服务器。 Does somebody know how to do this. 有人知道该怎么做吗? What adress i should use? 我应该使用什么地址?
Assuming that your devices are on the same Network (connected to the same router) as your computer, you can expose your computer's web server (Apache, presumably?) and then point your app directly at the local network IP address that your computer has (usually something like 192.168.1.x). 假设您的设备与计算机位于同一网络(连接到同一路由器)上,则可以公开计算机的Web服务器(大概是Apache),然后将应用程序直接指向计算机具有的本地IP地址(通常类似于192.168.1.x)。 I have found that the least painless way to do this is to use MAMP or WAMP or LAMP depending on your OS, but of course I have no idea what your specific situation is, so that solution may in fact make things a lot more complicated rather than less. 我发现最轻松的方法是根据您的操作系统使用MAMP或WAMP或LAMP,但是我当然不知道您的具体情况,因此该解决方案实际上会使事情变得复杂得多,反而比少。
In any event... your computer is on the network at a specific IP address, so it's just a matter of making sure that it's willing to serve this data on whatever port you are looking for it on. 无论如何,您的计算机都以特定IP地址在网络上,因此只需确保它愿意在要查找的任何端口上提供此数据。 If you provide more specification as to your circumstances, we can give a more detailed answer. 如果您提供有关您情况的更多说明,我们可以给出更详细的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.