Skip to content
Permalink
Browse files

serializing address through .getHostAddress() now instead of .toString()

using toString() of a InetAddress object caused a strange address string on some devices
  • Loading branch information...
dakhnod committed Jul 8, 2018
1 parent fa6a20d commit d00ef11c98d3fcc05aa7fd5db028025473736bc7
Showing with 4 additions and 4 deletions.
  1. +4 −4 app/src/main/java/d/d/meshenger/Utils.java
@@ -53,15 +53,15 @@ public static String getLinkLocalAddress() {
for (NetworkInterface nif : all) {
if (!nif.getName().equalsIgnoreCase("wlan0")) continue;

String fallBackAdress = null;
String fallBackAddress = null;
for(InterfaceAddress a : nif.getInterfaceAddresses()) {
if(a.getAddress().isLinkLocalAddress()){
return a.getAddress().toString().substring(1);
return a.getAddress().getHostAddress();
}else{
fallBackAdress = a.getAddress().toString().substring(1);
fallBackAddress = a.getAddress().getHostAddress();
}
}
return fallBackAdress;
return fallBackAddress;
}
} catch (Exception ex) {
}

0 comments on commit d00ef11

Please sign in to comment.
You can’t perform that action at this time.