mardi 17 mars 2015

connect to pc localhost via usb device

in my application i have localhost on pc and i want to connect to it from android, after set emulator to usb device and get ip address from command line i get this ip:



eth0 Link encap:Ethernet HWaddr 20:1a:06:c9:d6:f9
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0


now in my application i'm trying to set JSON connection url to 10.0.2.2 || 192.168.1.2 but i get an error:



Connection to http://10.0.2.2 refused


i think this below command resolve my problem but that could not do it



adb forward tcp:8080 tcp:8080


my wifi setting is disable now and after trying to enable that, it does not work and i can not connect to pc localhost



mahdi@mahdi:~ > ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.016 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.034 ms

Aucun commentaire:

Enregistrer un commentaire