How can I access my localhost from my Android device?

前端 未结 30 2363
面向向阳花
面向向阳花 2020-11-21 05:53

I\'m able to access my laptop web server using the Android emulator, I\'m using 10.0.2.2:portno works well.

But when I connect my real Android phone, th

30条回答
  •  Happy的楠姐
    2020-11-21 06:23

    Although one answer has been accepted but this worked for me:

    1. Make sure both your computer and android device are on same network.
    2. get your computer's ip address. (in case of mac type ifconfig inside terminal and look for en0/en1 -> inet it should be something like 19*.16*.1.4.) (on windows, use `ipconfig)
    3. Open your mobile settings and go to network-> long press your wifi network-> modify network -> scroll down to advanced options -> chose proxy manual and in proxy hostname type your address i.e. 19*.16*.1.4 inside port enter your port. and save it.

    4. search for what is my ip in google chrome, and get your ip, lets say it is 1**.1**.15*.2**

    5. try accessing 1**.1**.15*.2**:port/ from your mobile device.

    It is as simple as this.

提交回复
热议问题