安卓本地主机? [英] Android Localhost?

查看:152
本文介绍了安卓本地主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前有人问过并回答过这个问题,但我使用 10.0.2.2 作为模拟器.我听说我必须为我的真实设备使用其他东西.谁能告诉我那是什么?我可以让它们都运行 1 URL.而不是为模拟器和实际设备配备一个.

I know this has been asked and answered before, but I use 10.0.2.2 for the emulator. And I heard I must use something else for my real device. Can someone tell me what that is? And can I have them both run off of 1 URL. Instead of having one for the emulator and actual device.

推荐答案

Android 本地主机?

Android Localhost?

Android设备的

localhostlocalhost, 127.0.0.1.

localhost of an Android device is localhost, 127.0.0.1.

我用 10.0.2.2 做模拟器

I use 10.0.2.2 for the emulator

指的是运行模拟器的计算机的localhost.

That refers to localhost of the computer running the emulator.

我听说我必须为我的真实设备使用其他东西

And I heard I must use something else for my real device

您需要在计算机和设备共享的任何网络上使用计算机的 IP 地址.根据定义,您不能从另一台机器访问一台机器上的 localhost.

You need to use the IP address of the computer, on whatever network that the computer and the device share. You cannot access localhost on one machine from another machine, by definition.

当然,您还需要弄清楚在该计算机上运行的任何内容,以监听的不仅仅是它自己的 localhost.

Of course, you also need to figure whatever it is that is running on that computer to listen to more than its own localhost.

有没有一种方法可以让我使用单个 IP,而不是为我的模拟器使用 10.0.2.2 并为我的设备使用另一个 IP

Is there a way I can use a single IP Instead of using 10.0.2.2 for my emulator and having to use another one for my device

不是真的.此外,您所考虑的任何一个值很可能都不适合您的应用程序的发布版本.在那里,您将需要使用每个人的设备都可以访问的一些公开可见的服务器的域名(或者,在紧要关头,IP 地址).

Not really. Moreover, neither of the values that you are thinking of are the right ones for a release build of your app, in all likelihood. There, you will need to use the domain name (or, in a pinch, IP address) of some publicly-visible server that everyone's devices can reach.

这篇关于安卓本地主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆