Code example for WifiManager.MulticastLock

Methods: acquire, release, setReferenceCounted

0
        super.onCreate(savedInstanceState);
 
        try { 
            WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
            MulticastLock lock = wifi.createMulticastLock("wifi_multicast_lock");
            lock.setReferenceCounted(true);
            lock.acquire();
            NetworkDiscoverer.findPrinters(this);
            lock.release();
        } catch (DiscoveryException e) {
            new UIHelper(this).showErrorDialog(e.getMessage());
        } 
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java