Java tutorial
//package com.java2s; import android.content.Context; import android.net.DhcpInfo; import android.net.wifi.WifiManager; import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static InetAddress getBroadcastAddress(Context context) throws UnknownHostException { WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); DhcpInfo dhcp = wifi.getDhcpInfo(); if (dhcp == null) { return InetAddress.getByName("255.255.255.255"); } int broadcast = (dhcp.ipAddress & dhcp.netmask) | ~dhcp.netmask; byte[] quads = new byte[4]; for (int k = 0; k < 4; k++) quads[k] = (byte) ((broadcast >> k * 8) & 0xFF); return InetAddress.getByAddress(quads); } }