How can I access my localhost from my Android device?

前端 未结 30 2251
面向向阳花
面向向阳花 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条回答
  •  北海茫月
    2020-11-21 06:41

    First of all make your machine(where server is running)IP address static. Enter this static IP address in the android code. Next go to your wifi router's interface and check the left panel. You will see option such as port forwarding/forwarding. Click on it and forward port 80. Now edit your htttpd.conf file and edit it for

    Allow from All

    . Restart your server. Everything should work fine now.

    Additionally you can reserve the IP address of your machine so that it is always allocated to you. In the left panel of your router's interface, find DHCP -> Address Reservation, click on it. Enter your machine's MAC address and the IP address you have entered in the code. Click on save. This will reserve the given IP address for your machine.

提交回复
热议问题