职业网络成瘾者 • 游戏爱好者 • 技术创造者
职业网络成瘾者 • 游戏爱好者 • 技术创造者

如何从 Android 连接到本地 Google App Engine 网站

如何从本地主机上的 Android 模拟器连接到您的 Google App Engine 网站,而不会出现 ConnectException!
为了方便您使用,本页面由我热情高涨的 AI 实习生从英文翻译而来。他们仍在学习中,因此可能存在一些错误。为了获得最准确的信息,请参考英文版本。
博客 如何从 Android 连接到本地 Google App Engine 网站

请注意,本博文发布于2011年6月,因此根据您阅读的时间,某些部分可能已过时。很遗憾,我无法始终保持这些文章的完全更新,以确保信息的准确性。

    If you are trying, from your Android application through the Android emulator, to access an external service on the same computer (such as your own Google App Engine site) by using the host name localhost or the IP-address 127.0.0.1, you might get a java.net.ConnectException java.net.ConnectException: localhost/127.0.0.1:8888 - Connection refused error - even though you can perfectly well access the service outside the Android application.
    The reason why a ConnectException occurs is because "localhost" or "127.0.0.1" inside the Android emulator is the emulator's own loopback interface, meaning all request sent to the destination will be looped backed to the emulator and won't actually be sent to your local machine.
    To by pass this, simply replace "localhost" with the IP-address "10.0.2.2", as this is a special address towards the real local host.
    Done!

    作者:Special Agent Squeaky。首次发布于2011年6月3日。最后更新于2011年6月3日。

    📺 快来看看 Squeaky 的最新视频!

    如何为您的直播添加简单的实时字幕