Code Poet
Code Poet

Reputation: 11437

Accessing host loopback interface from device?

I've been so far running my app exclusively in the emulator. I want to try it out on a real device. My app connects to a web service running on the localhost itself using the host loopback IP of '10.0.2.2'.

I have got the application deployed on my phone, but I don't know how to access a url like: "http://10.0.2.2/xyz/controller/AppController.php" when the application is on the phone.

Basically, I want my phone to connect to the web server running on my machine. My machine is a dev machine and doesn't have a static ip. Is it possible?

I understand I can deploy my web app on a real server with static ip and use that in my code.

Upvotes: 1

Views: 2105

Answers (2)

rekire
rekire

Reputation: 47955

Check if you use the Emulator with "google_sdk".equals(Build.PRODUCT); or with "sdk".equals(Build.PRODUCT); depending on the used sdk.

And connect to your local network ip (or computername) or with port forwarding the public ip (using ddns) of your router.

Upvotes: 0

nwaltham
nwaltham

Reputation: 2084

If you have a network routable address on your PC you can register it with a service like DynDNS, alternatively if you can connect with Wifi to your PC on your LAN, you can access it with that.

Upvotes: 1

Related Questions