acquire Wifi Multicast - Android Wifi

Android examples for Wifi:Wifi Connection

Description

acquire Wifi Multicast

Demo Code


//package com.java2s;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.MulticastLock;

public class Main {
    private static MulticastLock wifiMulticastLock;

    public static boolean aquireWifiMulticast(Context context) {
        boolean result = false;
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        if (wifiManager != null) {
            wifiMulticastLock = wifiManager
                    .createMulticastLock("PdDroidPartyMulticastLock");
            wifiMulticastLock.acquire();
            result = wifiMulticastLock.isHeld();
        }/* w  w w.  ja v  a  2 s .  c om*/
        return result;
    }
}

Related Tutorials