Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 702947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:46:37+00:00 2026-05-14T03:46:37+00:00

My activity needs to communicate with a java server located on my dev machine.

  • 0

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 ?

edit:
Just added different scenarios to let everyone understand better:

1. Emulator-based scenario:

  • standard java server running on my pc @localhost:15000
  • android java client running on my emulator.

When the android app needs to contact the server it uses 10.0.2.2:15000 like specified here.
Everything works fine.

2. Proper wifi scenario with physical connected device:

  • standard java server running on my pc @192.168.1.10:15000.
  • android java client running on my device with 192.168.1.11 address assigned.

When the android app needs to contact the server it uses 192.168.1.10:15000 and everything works fine too.

3. Desired scenario:

  • standard java server running on my pc @localhost:15000.
  • android java client running on my device connected via usb cable. No network is active.

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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:46:38+00:00Added an answer on May 14, 2026 at 3:46 am

    It seems like there’s no way to let scenario #3 work properly, because usb connection is not a real network connection and there’s no ip associated to it by the phone.

    Actually my solution is to use an ad-hoc wifi connection between my phone and my pc. This scenario is similar to #2, but without router or dhcp. Unfortunately my Hero can’t handle ad-hoc connections natively because of this issue. So I had to root my device and to change manually some config script. I hope functionality like this can be available in next releases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity which needs to make two remote server calls. The first
i'm creating an activity which needs to upload an image to a webservice using
I have a non-Activity class (let's call it NonActivity) that needs to post a
I have a program that needs to... In Activity A , do some jobs
I understand an activity needs to be defined/described in the AndroidManifest xml file. I
This is the scenario: User has a main activity used for UI. Program needs
I have activity which needs to be active all the time. I have thread
I have two activity in my app say A & B. Activity A needs
I have an Activity that usually needs some time to watch the screen without
I've got a live wallpaper that I'd like to communicate with from an Activity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.