becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

getHostName on Android 8 and 10 failing #93

Closed semidark closed 3 years ago

semidark commented 3 years ago

the getHostName function in ZeroConf.java is misbehaving under Anrdoid 8 (Samsung Galaxy S8) and Android 10 (Samsung S10 and Emulated Pixel 3a)

The Function getString.invoke(null, "net.hostname").toString(); is not returning an empty string but the string "unknown".

So I had to add this possibility to the following if clause: if (TextUtils.isEmpty(hostName)) { It now looks like this in my project: if (TextUtils.isEmpty(hostName) || hostName == "unknown") {

semidark commented 3 years ago

Made a fork and a Pull request for this little fix.

emcniece commented 3 years ago

Resolved in https://github.com/becvert/cordova-plugin-zeroconf/pull/94