When using some Android devices (such as my Xiaomi phone), the device cannot be discovered by my computer. I changed the destination address of the device to send the udp packet and changed it to [network address .255] instead of the original 255.255.255.255, which solved the problem.
Details
Details
Diff Detail
Diff Detail
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Comment Actions
Thanks for the patch! I noticed some connectivity issues myself so I'm very interested in seeing if this improves the situation for me. I will test it over the next few days.
However, there are some things that need to be improved:
- This needs the permission ACCESS_WIFI_STATE or else it crashes for me
- You removed the add-by-IP handling, please add it again
- Not all broadcast addresses end with .255, for example 192.168.0.1 with netmask 255.255.255.128 has 192.168.0.127 as broadcast address. You should be able to get the broadcast address from the NetworkInterface object (https://stackoverflow.com/a/9912504)
Comment Actions
Improved:
- Add
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
to AndroidManifest.xml, I found that I can only upload one diff file, so you have to add it manually.
- Added back, but I think that they may be useless.
- The code can get the right broadcast address, in my case, it is [network address.255].