How can i access my localhost from my android device?
-
Am able to access my laptop web server using the android emulator, am using 10.0.2.2:portno works well. But when i connect my real android phone, the phone browser cannot connect to the same web server on my laptop. The phone is connected to the laptop using a USB cable. If i run the adb devices command, i can see my phone. What am i missing? Gath
-
Answer:
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.
gath at Stack Overflow Visit the source
Other answers
There is however a far better solution. You can access your host machine with the IP address "10.0.2.2". This has been designed in this way by the Android team. So your webserver can perfectly run at localhost and from your Android app you can access it via "http://10.0.2.2:8080".
Akhil Jain
I found a quick solution to this problem. try this link, it should help you guys fix the problem. http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi/ I only changed 1 thing, where the tutorial states you change '127.0.0.1' to 'All', change it to the ip address your server is running on instead. after that you should be able to connect to your localhost.
GertV
Related Q & A:
- How can i access the number of questions asked on stackoverflow?Best solution by Meta Stack Overflow
- How can I pause and restart animations in Android?Best solution by Stack Overflow
- How can I access file in localhost?Best solution by Stack Overflow
- How can I improve the battery life on my device?Best solution by Android Enthusiasts
- How do I clear our memory on an Android device?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.