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

  • SEARCH
  • Home
  • 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 9186097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:26:24+00:00 2026-06-17T19:26:24+00:00

I want to use the following code for my application: InetAddress inetAddress; try {

  • 0

I want to use the following code for my application:

InetAddress inetAddress;
try {
        inetAddress = InetAddress.getByName(hostname);
} catch (UnknownHostException e) {
        return -1;
}

It works well on most of the devices I’ve tested but on the Nexus S Europe and a Huawei device, it throws an exception.

cannot establish route for 192.168.010.200: unkown host

I’ve already tried to fix it using the following code in my Application class, but without success:

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
StrictMode.setThreadPolicy(policy);

I’ve also tried to use AsyncTask but I got the same error. Here is the code I used:

private int mInetAddr = -1;
private boolean mInetAck = false; // Acknowledgement

private class AsyncInetAddress extends AsyncTask<String, Void, Void>
{
    @Override
    protected Void doInBackground(String... hostname)
    {
        InetAddress inetAddress;
        try
        {
            inetAddress = InetAddress.getByName(hostname[0]);
        }
        catch (UnknownHostException e)
        {
            mInetAddr = -1;
            return null;
        }

        byte[] addrBytes;
        int addr;
        addrBytes = inetAddress.getAddress();
        addr = ((addrBytes[3] & 0xff) << 24)
                | ((addrBytes[2] & 0xff) << 16)
                | ((addrBytes[1] & 0xff) << 8)
                | (addrBytes[0] & 0xff);
        mInetAddr = addr;
        return null;
    }

    @Override
    protected void onPostExecute(Void result)
    {
        mInetAck = true; // Acknowledgement
    }
}

Do you have any idea on how I could fix that ?

Thanks.

Edit: I’ve tried on some other devices, problem looks to be present only on version 4.0.* . Works great on 2.* , 3.* and 4.1+.

Now the problem is located at that line:

 if (!connMgr.requestRouteToHost(2, inetAddr))

Where inetAddr = -938825536. The first param is the MMS type. The condition is always true under a device running 4.0.3 or 4.0.4.

  • 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-06-17T19:26:25+00:00Added an answer on June 17, 2026 at 7:26 pm

    Problem solved.
    It can’t find the route to IP while the wifi is enabled. Simplest way is to disable wifi, do your stuff and then enable wifi.

    Here is the code I used:

    // Disable wifi if it's active
    WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager.isWifiEnabled())
    {
          mWasWifiActive = true;
          wifiManager.setWifiEnabled(false);
          Log.e(TAG, "Wifi was enabled, now Off.");
    }
    
    // Do stuff here
    
    // Re-enable wifi if it was active before routing
    if (mWasWifiActive)
    {
           WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
           wifiManager.setWifiEnabled(true);
           Log.e(TAG, "Wifi is back online.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the following code for a high-concurrency application where certain data
I want to use the following code to login to a website which returns
In the following code I want to use the dilate function but I don't
I use the following code to layout network drives on a system. I want
I want to use pygments with jekyll I have the following code: {% highlight
I have one grid view in my web application. I use the following code
I want to use the following piece of code but it won't let me,
I want to embed a video in the webpage, I use the following code:
I want to use the following command: openssl x509 -noout -in /etc/pki/tls/certs/cert1.pem -enddate openssl
I want preserve original value of target field and use json_decode to use following

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.