问题
Trying to execute the following line
NsdManager Mgr = (NsdManager)Ctxt.getSystemService(Context.NSD_SERVICE);
in the Android 5.0 emulator (ARMv7a, on Win64) freezes the emulator. The debugger never reaches the next line, the emulator doesn't respond to buttons, can be only closed.
Tried from both a background thread and from the main one. The context is an Activity.
Permissions in the manifest include:
- android.permission.INTERNET
- android.permission.ACCESS_WIFI_STATE
- android.permission.CHANGE_WIFI_STATE
- android.permission.CHANGE_WIFI_MULTICAST_STATE
The same line works as expected on a 4.4 emulator and on a 4.1 device. Any ideas what's different on 5.0 and/or what's wrong with the line, please? Did anybody try this on a 5.0 device?
EDIT: same on Intel emulator.
回答1:
NSD in Android is all kinds of broken. Don't even try to make it work, go back to JmDNS.
These are the damning bug reports:
https://code.google.com/p/android/issues/detail?id=35585 https://code.google.com/p/android/issues/detail?id=39750
Also, Nsd Manager Android Crashing on 4.2.2
来源:https://stackoverflow.com/questions/27281340/getsystemservicecontext-nsd-service-freezes-the-5-0-emulator