Reputation: 393
I have Spring MVC web application which I want to connect with mine android application in order to use the rest services. I am working with my android phone, ALCATEL ONE TOUCH POP D5, but I didn't succeeded to connect it to access the localhost. I tried with finding my ip address with ipconfig and type it in the browser of the phone, but it doesn't show anything. I also, enabled port 80 in Windows Firewall. I tried with usb tethering, also failed.
My laptop and my android device are on the same network, and I use the phone's network with Wi-Fi tethering.
I would like someone to explain me, the whole scenario about connecting the android device to localhost?
I tryed the solutions from various questions, but they don't seem to work for me, or I am skipping something. Here are the solutions I tried: How can I access my localhost through Android phone? Accessing localhost of PC from USB connected Android mobile device
Upvotes: 0
Views: 6802
Reputation: 20699
I used the local network IP-addresses like 192.168.0.*
to communicate with the server from my smartphone. Both devices must be in the network of course
Upvotes: 1
Reputation: 5840
This is what i do:
Upvotes: 0
Reputation: 21
I generally use the following approach :
1) Run the web server on local ip of computer on network rather than localhost . In python to accomplish this I run ipconfig in terminal and then do python manage.py runserver [ip]:8000 where ip is ip of computer on network from ipconfig.You can find similar thing for your framework.
See this Link for above implementation :-
Serve Django project on local WiFi Network
2) Then when I hit that IP from any device on same network . I could see the web application running . So same goes for android application . You can access it as normal URL in android.
Upvotes: 2
Reputation: 762
USB doesn't provide network to mobile device. If it's connected to your wifi, then hit your laptop address provided by the router. If it's connected to your mobile network, then first find out your router external IP address, then forward some port to that 10.0.2.2:portno and finally you'll be able to see that server from your device.
Upvotes: 1