Android 4.0.3和4.0.4下的requestRouteToHost问题,但不包括其他问题

Android 4.0.3和4.0.4下的requestRouteToHost问题,但不包括其他问题,android,device,android-version,Android,Device,Android Version,对于个人项目,我必须检查是否可以访问用于彩信的设备LAN ip。 我已经找到了带有提供的APN的IP。现在我需要使用requestRouteToHost方法来检查找到的代理是否有效 该代码在运行Android2.3到4.0以及从4.1到更高版本的设备上完美运行。 但它在4.0.3和4.0.4下给了我一个错误。我在多台设备上测试过,这不是设备问题,而是版本问题 if (!connMgr.requestRouteToHost(2, inetAddr)) { Log.e(TAG, "unab

对于个人项目,我必须检查是否可以访问用于彩信的设备LAN ip。 我已经找到了带有提供的APN的IP。现在我需要使用
requestRouteToHost
方法来检查找到的代理是否有效

该代码在运行Android2.3到4.0以及从4.1到更高版本的设备上完美运行。 但它在4.0.3和4.0.4下给了我一个错误。我在多台设备上测试过,这不是设备问题,而是版本问题

if (!connMgr.requestRouteToHost(2, inetAddr)) {
     Log.e(TAG, "unable to request route to host");
     throw new IOException("Cannot establish route to proxy " + inetAddr);
} else {
     Log.e(TAG, "route to host requested");
}
第一个条件总是正确的,这是一个真正的问题

上面的代码包含在我制作的AsynTask中:

private class AsyncRoute extends AsyncTask<String, Void, Void>
{
    @Override
    protected Void doInBackground(String... proxyAddr)
    {
        try
        {
            ensureRouteToHost(proxyAddr[0]);
            Log.e(TAG, "OK ACK");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        mInetAck = true;
        return null;
    }
}
基本上,它在执行两个请求之前等待确认

那么,有人知道是否有一个技巧可以绕过这个问题吗?我的意思是,有没有一种方法可以像connMgr.requestRouteToHost(2,inetAddr)那样在每台设备上都能工作

谢谢

Ps:在Desire S 2.3、Desire S 4.0.3、Xperia lt30p 4.0.4、Nexus S 4.0.3等上进行测试

编辑:在引发异常的设备上,路由IP上的ping命令起作用:

> adb shell ping 192.168.10.200
PING 192.168.10.200 (192.168.10.200) 56(84) bytes of data.
64 bytes from 192.168.10.200: icmp_seq=1 ttl=251 time=4023 ms
64 bytes from 192.168.10.200: icmp_seq=5 ttl=251 time=81.3 ms
但路由请求失败:问题已解决。 启用wifi时,它找不到IP的路由。最简单的方法是禁用wifi,完成自己的工作,然后启用wifi

以下是我使用的代码:

// 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.");
}
// 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.");
}