Skip to content

Commit

Permalink
serializing address through .getHostAddress() now instead of .toString()
Browse files Browse the repository at this point in the history
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 d00ef11
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/d/d/meshenger/Utils.java
Expand Up @@ -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) {
}
Expand Down

0 comments on commit d00ef11

Please sign in to comment.