Getting Android to talk to Apache on localhost

后端 未结 5 1232
庸人自扰
庸人自扰 2020-12-24 15:20

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 b

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 16:25

    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:

    • 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.

    • 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)

    • 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.

提交回复
热议问题