2011-04-05 48 views

回答

2

您不能设置IP地址。你可以得到ip地址

public static String getIPAddress() { 

    int apnId = 0; 
    try { 
     apnId = RadioInfo.getAccessPointNumber("MagicRudyAPN.rim"); 
    } catch (RadioException e) { 
     Log.e(e); 
     e.printStackTrace(); 
    } 

    byte[] ipByte = RadioInfo.getIPAddress(apnId); 
    String ip = ""; 
    for (int i = 0; i < ipByte.length; i++) { 
     int temp = (ipByte[i] & 0xff); 
     if (i < 3) 
      ip = ip.concat("" + temp + "."); 
     else { 
      ip = ip.concat("" + temp); 
     } 
    } 

    Log.s(TAG + "Returning IP=" + ip); 
    return ip; 
} 

请检查http://supportforums.blackberry.com/t5/Java-Development/wifi-ip-address/m-p/374279了解详情。