How i can connect from localhost to android emulator? - android

Many people ask about "How get the connect from a emulator to localhost". I am asking about a reverse issue. I created a tiny http server in android app. I know his ip address and want to connect from my chrome browser to the app. If i use my a phone it is no problem, because app use "outer" ip, but in local net wifi. When i use a emulator on a development machine and open in browser ip 10.0.2.15 then can not get access to app in emulator. I tryed any ways - loopback, forward ... all is not working.

Related

Debug mobile app from Chrome - localhost not resolved

I remember with another phone I was able to debug my local website dev, now there is a problem preventing me to open localhost in my mobile and cannot find how.
Looking at:
Google Chrome for Android Remote Debugging - "localhost:9222" Not Available
my phone is connected, on localhost:9222 I can see a list of tabs.
I can access tabs loading site from remote, but cannot load my localhost.
In one case, error displayed:
408 - Timeout.
On another , simply chrome display site is not reachable.
ERR_NAME_NOT_RESOLVED
I tried both with port-forward enabled as well as not (if enabled, listening to 8081, 8080).
Phone is connected via USB but seems cannot reach my localhost address of the laptop, still on same wifi spot.
EDITED
I remember with another phone I was able to debug my local website
dev, now there is a problem preventing me to open localhost in my
mobile and cannot find how.
I was doing with Bonjour- the "Bonjour host" is the name Mac assign to your user machine user.local. I was able to connect former android host, but now it cannot be solved anymore unless of IP.
The two devices should be on the same network and it won't be localhost in that case, but you have to replace localhost with the IP of the server PC!
So instead of localhost:9222, it would be 192.168.1.10:9222 giving that 192.168.1.10 is your IP address!

My android phone does not connect to my apache local server

I'm developing an android app that connect with a restful web service which is on my tomcat local server.
The app works well on the emulator, however, it doesn't work on my real mobile.
I use the IP from ipconfig, and both my laptop and my phone connected to the same Wi-Fi.
I tried to call the web service from the mobile browser but still, it doesn't see my localhost :(!
it shows me :
This site cannot be reached.
I searched a lot and all the solutions say that I have to connect both to the same Wi-Fi network and to use the IP from ipconfig command, which I did!
How can I fix this?
PS: I'm using 9090 as my port number, I don't know if that a reason?
Thank you.

Accessing localhost in android application

I am making an application that needs to access the server database.
But since its still in the early stage, I have to delete the database quite often which is a problem because its used for other web applications too.
So I was thinking if I could test my application against my localhost database it would make it much easier for me.
I tried a few solutions on stack overflow but they didn't work for me so here is my problem.
I have lamp setup on my system.
In my browser, I can access localhost using 127.0.0.1 but if I try the same thing on my phone's browser it shows that the connection was refused.
Both my laptop and phone are connected to the same wifi network.
Is there some permission I have to provide that I am not aware of?
your 127.0.0.1 refers to your desktop.
Find out the local ip of your desktop (example 192.168.0.2) and then use that ip on your mobile browser
You should try to access to your laptop by using its IP address.
If your laptop is running on Windows, run the command ipconfig from a Command Prompt Window and then use the ip address the command returned on your phone's browser.
This should work.

Android Simulator how does it connect to local IP addresses?

I am trying to implement an Android application in Windows 7 using Eclipse. I am trying to connect the Android simulator to the local test server in my company, but for some reason, it cannot connect to the test server.
If there is any settings or configurations for this, please let me know.
I have tried to do the same from a MAC machine using iPhone emulator and I am facing the same problem. How would this emulator connect to the local servers in my company as currently it all goes to live servers? What configurations are required to be done on the simulators, and how?
If I try to connect to the test server from normal Windows machine browser, I am able to successfully connect to it through the web browser; but when I try to do the same from the Android emulator browser, it cannot connect to it.
The emulator points to the live network and not the local network in my company. This is strange and I know that I need to do some settings for it, but I am not sure where these settings are done and how.
If accessing local computer:
http://localhost:8080/MyLocalServer.html // URL to use in computer browser
http://10.0.2.2:8080/MyLocalServere.html // URL to use in emulator browser
Also try using a local IP to connect to any local servers. Do not use host names.
Dont:
http://mylocalserver.org/
Do:
http://192.168.1.125:portnumber
You have to set up IP-based hosts instead of name-based.
Emulator its - VM. This use virtual network connection. I think you need before chech this connection (this connection may bee stay as NAT, Breedge, Native IP adress, Proxy).
Since you do not work iPhone emulator, most likely you, IP adress virtual network connectionб which uses Emulator, does not match the address area of the local network, and routing occurs
This may help you...
Taken from the android docs:
If you need to refer to your host computer's localhost, such as when you want the emulator client to contact a server running on the same host, use the alias 10.0.2.2 to refer to the host computer's loopback interface. From the emulator's perspective, localhost (127.0.0.1) refers to its own loopback interface.
http://developer.android.com/guide/faq/commontasks.html#localhostalias

libcurl & android connecting to a web service at localhost

I've managed to connect my app to a web service but I have a problem with the android platform. (If someone doesn't know, with cocos2d-x you can make multiplatform apps)
Right now, the web service is hosted at "http://127.0.0.1:9876/ts?wsdl" at localhost.
I've managed to generate requests for it and it works great in the win32 app. The problem comes when I try to connect to the web service with the android app. It will always give "code: 7" (couldn't connect) but the funny thing is that it will work if I connect to whatever hosted server.
So I wonder why it won't let me connect to localhost, also note that I'm using the emulator since I don't have a device but I don't think that's the problem.
Any ideas?
I assume you are using an emulator instead of a phone. So when you type localhost, it refers to the ip address of the phone, not your pc. Android provides you an ip address which maps to your PCs localhost. So use 10.0.2.2. instead of localhost and it should work.

Categories

Resources