获取Android的谈话到Apache在localhost [英] Getting Android to talk to Apache on localhost

查看:128
本文介绍了获取Android的谈话到Apache在localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序的会谈到PHP服务器。我的Apache / PHP的WAMP服务器上本地运行。我运行Windows 7。如果我去到localhost在Windows 7的网站显示,但手机会查找本地主机目前的Andr​​oid操作系统,所以没有网站显示上。

My Android application talks to a php server. I have Apache/php running locally on WAMP Server. I am running Windows 7. If I go to localhost on Windows 7 the site shows but on the phone it will look for localhost on the current Android OS so no site shows.

我设法解决这个问题通过打开我的Apache配置到互联网,然后用我的外部IP地址,这是烦人,因为我是一个动态IP,有时没有互联网(+不安全)。

I managed to get around this by opening my apache configuration to the internet and then using my external IP address, this is annoying because I am on a dynamic IP and sometimes don't have internet (+ not secure).

我如何从Android的访问本地主机(或主机文件中的另一个别名)一个http请求?

How do I make a http request from android access localhost (or another alias in the hosts file)?

推荐答案

乔恩是正确的,在一般情况下,你不能让Android设备的Andr​​oid模拟器连接通过USB电缆与电脑连接(一个主要的区别在哪里这样的连接由一个别名地址来实现)。不过,也有一些事情你可以做的:

Jon is correct that in the general case you cannot make the android device connect to a pc through the usb cable (a major difference from the android emulator where such connection is accomplished by an alias address). However, there are some things you can do:

  • 您既可以在PC和手机连接到一个安全的无线路由器。它甚至不需要有一个上行网络连接。

  • You can connect both the pc and the phone to a secured wifi router. It doesn't even need to have an upstream internet connection.

显然,如果你有升级Froyo和USB绑定选项,就会把这个作为一个副作用建立联网通过USB,让手机与个人电脑(只是看在您的电脑的互联网流量是怎么回事虽然)

Apparently, if you have froyo and the usb tethering option, turning this on will as a side effect establish networking over USB that allows the phone to contact the pc (just watch where you pc's internet traffic is going though)

如果你想要的东西在电脑上打开的东西连接监听的手机上,你可以使用亚行端口转发。但是,这听起来像你想在PC上的客户端与服务器联系的手机上,这样就不会工作。

If you wanted something on the pc to open a connection to something listening on the phone, you could use an adb port forward. But it sounds like you want a client on the pc to contact a server on the phone, so that won't work.

这篇关于获取Android的谈话到Apache在localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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