Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess dev machine localhost via usb
    primarykey
    data
    text
    <p>My activity needs to communicate with a java server located on my dev machine. Actually, using the emulator, I can access the server socket via the special 10.0.2.2 address. Now I'd like to test my app on my phone connected via usb, but it seems like I can't use 10.0.2.2 to access my dev machine localhost anymore. Naturally using a wifi router and a proper lan addressing does the trick, but I need to use usb connection instead. Any hint ?</p> <p>edit:<br/> Just added different scenarios to let everyone understand better:</p> <p><strong>1. Emulator-based scenario:</strong></p> <ul> <li>standard java server running on my pc @localhost:15000</li> <li>android java client running on my emulator.</li> </ul> <p>When the android app needs to contact the server it uses 10.0.2.2:15000 like specified <a href="http://developer.android.com/intl/fr/guide/developing/tools/emulator.html#emulatornetworking" rel="noreferrer">here</a>. Everything works fine.</p> <p><strong>2. Proper wifi scenario with physical connected device:</strong></p> <ul> <li>standard java server running on my pc @192.168.1.10:15000.</li> <li>android java client running on my device with 192.168.1.11 address assigned.</li> </ul> <p>When the android app needs to contact the server it uses 192.168.1.10:15000 and everything works fine too.</p> <p><strong>3. Desired scenario:</strong></p> <ul> <li>standard java server running on my pc @localhost:15000.</li> <li>android java client running on my device connected via usb cable. No network is active.</li> </ul> <p>When the android app needs to contact the server it tries to connect to 10.0.2.2:15000 but instead an exception is thrown (Network unreachable). It seems like special address 10.0.2.2 works only for emulator instances.</p> <p>I just wonder if in the adb/adt suite there's a way to access pc address from the device connected via usb cable. I hope it's a bit more clear now. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload