3

I have my droid device connected through USB and using Eclipse for debugging my application running on the device. Everything is fine, except my application needs to connect to a web application running on the same host computer (Windows XP, IE). The web address on the IE was "http://local:4566/MyApp/".

I tried to set my android app to "http://10.0.2.2:4566/MyApp", but no luck. The android app's connection simply times out. The document under http://developer.android.com/guide/developing/tools/emulator.html says that the ip address may be different for devices (see Network Address Space section) but no further details on how to find that.

Question is, how to I connect to a local web application running on my host computer (windows xp) from an Android application connected through USB running debug under Eclipse?

Appreciate any help.

thanks, Guna

guna
  • 31
  • 1
  • 2
  • Did you try replacing 10.0.2.2 with the name of your local machine or its ip address? – Vino Feb 20 '11 at 18:38

3 Answers3

2

Question is, how to I connect to a local web application running on my host computer (windows xp) from an Android application connected through USB running debug under Eclipse?

Use the IP address of the of XP machine. This will only work if the "droid device" and the XP machine are on the same network (e.g., WiFi).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I tried replaceing 10.0.2.2 with the IP address of my local machine. My droid is connected through USB to the windows xp where I also run my Web application. It doesn't help. – guna Feb 20 '11 at 19:46
  • 1
    just for clarifications, the 10.0.2.2 works fine with emulator, only not with the USB connected device. My application connects with external hosted applications. – guna Feb 20 '11 at 19:51
  • @guna: "My droid is connected through USB to the windows xp where I also run my Web application." -- this makes no difference whatsoever. "It doesn't help." -- yes, it does. You have other problems (e.g., your Web app only works with `localhost`, the "droid device" is not on the same network as the PC hosting the Web app). "the 10.0.2.2 works fine with emulator, only not with the USB connected device." -- of course. It is only documented to work on the emulator. The page you link to above is entitled "Android Emulator". Your "droid device" is not the Android emulator. – CommonsWare Feb 20 '11 at 20:50
  • @CommonsWare what if we enable USB tethering(some devices have this feature)? this way, I think they will be on the same network. – Timuçin May 16 '12 at 11:10
  • @Tim: Right now, I am tethered to a Galaxy Nexus (curse you, unreliable conference hotel WiFi!). My Ubuntu notebook has a 192.168.* IP address. My phone has a 22.176.* IP address courtesy of T-Mobile. Now, it is possible that the phone has two IP addresses, and the IP address app widget I am using only reports one. – CommonsWare May 16 '12 at 11:48
  • @CommonsWare I am tethered to a Samsung Tab via usb. On my pc, I can see a connection named "Samsung Mobile USB Remote NDIS Network Device". In details, its ip address: 192.168.42.69 and I can ping this address on my pc. This means I can ping the device from PC. But I dont know which address I must enter to ping the PC from device. Generally these addresses will be predefined addresses like "10.0.2.2" but I dont know what it is. – Timuçin May 16 '12 at 14:04
1

The usb cable is not a 'network' cable and the two machines are separate, really.

you need to create an ad hoc network between the local host and the android device. search for "windows create ad hoc network" depending on your windows version. when set up, your android can see it in its access point list.

p.s. as for debugging, set the security type to minimum, so that you dont need any additional tweaks.

olix20
  • 794
  • 1
  • 11
  • 23
-3

Get the IP address of your device by going to a website such as http://www.whatismyip.com using your device. This will allow you to know what the actual IP address of your device is.

Rob W
  • 341,306
  • 83
  • 791
  • 678
Joe
  • 7