连接到在模拟器中的Android应用程序中运行的自托管Web服务

时间:2022-06-12 18:56:06

I implemented a web-service in Android app listening to a port. I have another console desktop app which connects to it.

我在Android应用程序中实现了一个侦听端口的Web服务。我有另一个连接到它的控制台桌面应用程序。

This works fine when running the Android app on device. On emulator, it's a problem because it's basically same connection with computer.

这在设备上运行Android应用程序时工作正常。在模拟器上,这是一个问题,因为它与计算机基本相同。

How can I connect to the web-service running in the emulator?

如何连接到模拟器中运行的Web服务?

1 个解决方案

#1


You can (and should) use Genymotion as emulator (https://www.genymotion.com/). It's more performant than original emulator and use virtual machine mecanism. Therefore, your emulator will have his dedicated (but virtual) network interface. Allowing it to have its own IP address.

您可以(并且应该)使用Genymotion作为模拟器(https://www.genymotion.com/)。它比原始模拟器更高效,并使用虚拟机机制。因此,您的模拟器将具有其专用(但虚拟)网络接口。允许它拥有自己的IP地址。

This will make sockets listening available on your local network.

这将使您的本地网络上的套接字可用。

#1


You can (and should) use Genymotion as emulator (https://www.genymotion.com/). It's more performant than original emulator and use virtual machine mecanism. Therefore, your emulator will have his dedicated (but virtual) network interface. Allowing it to have its own IP address.

您可以(并且应该)使用Genymotion作为模拟器(https://www.genymotion.com/)。它比原始模拟器更高效,并使用虚拟机机制。因此,您的模拟器将具有其专用(但虚拟)网络接口。允许它拥有自己的IP地址。

This will make sockets listening available on your local network.

这将使您的本地网络上的套接字可用。