I want to broadcast from an android device which acts as a hotspot, but using 255.255.255.255 does not work as UDP broadcast in android. But 192.168.1.255 this broadcast address works. When I check the IP address of my device its shows 192.168.1.4.
Now how to calculate address 192.168.1.255 from this address?
Well, if you have the broadcasting worked out and only need to change the last byte of the address to 255, you can do the following:
Pulling the broadcast address directly from the NetworkInterface, results in this code:
You may have to sift through the NetworkInterface to find the one corresponding to the internal ip.