当前位置: 首页>>代码示例>>Java>>正文


Java WifiManager.createMulticastLock方法代码示例

本文整理汇总了Java中android.net.wifi.WifiManager.createMulticastLock方法的典型用法代码示例。如果您正苦于以下问题:Java WifiManager.createMulticastLock方法的具体用法?Java WifiManager.createMulticastLock怎么用?Java WifiManager.createMulticastLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.wifi.WifiManager的用法示例。


在下文中一共展示了WifiManager.createMulticastLock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NSLoggerClient

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
/**
 * Create a new NSLoggerClient instance. Multiple instances will create multiple log windows on
 * the desktop viewer, or you can have instances that log to a file and others that
 * log to the desktop viewer. Typically, you will use only one instance.
 * Default options are to lookup for a desktop viewer on Bonjour, and use SSL
 * @param ctx	the current context, which is used to extract and send information about the client application
 */
public NSLoggerClient(Context ctx)
{
	if (DEBUG_LOGGER)
		Log.i("NSLogger", "NSLoggerClient created");
	currentContext = ctx.getApplicationContext();

	// create the multicast lock (for Bonjour) if needed, otherwise the WiFi adapter
	// doesn't process multicast packets when needed. We will acquire the lock ONLY
	// while looking for a Bonjour service to connect to, and will release it as soon
	// as we acquire an actual connection to the service.
	if (multicastLock == null)
	{
		synchronized (this.getClass())
		{
			if (multicastLock == null)
			{
				WifiManager wifi = (WifiManager)ctx.getSystemService(Context.WIFI_SERVICE);
				multicastLock = wifi.createMulticastLock("NSLoggerBonjourLock");
				multicastLock.setReferenceCounted(true);
			}
		}
	}

	options = (OPT_BROWSE_BONJOUR | OPT_USE_SSL);
}
 
开发者ID:intari,项目名称:CustomLogger,代码行数:33,代码来源:NSLoggerClient.java

示例2: UDPSocketServer

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
/**
 * Constructor of UDP Socket Server
 * 
 * @param port
 *            the Socket Server port
 * @param socketTimeout
 *            the socket read timeout
 * @param context
 *            the context of the Application
 */
public UDPSocketServer(int port, int socketTimeout, Context context) {
	this.mContext = context;
	this.buffer = new byte[64];
	this.mReceivePacket = new DatagramPacket(buffer, 64);
	try {
		this.mServerSocket = new DatagramSocket(port);
		this.mServerSocket.setSoTimeout(socketTimeout);
		this.mIsClosed = false;
		WifiManager manager = (WifiManager) mContext
				.getSystemService(Context.WIFI_SERVICE);
		mLock = manager.createMulticastLock("test wifi");
		Log.d(TAG, "mServerSocket is created, socket read timeout: "
				+ socketTimeout + ", port: " + port);
	} catch (IOException e) {
		Log.e(TAG, "IOException");
		e.printStackTrace();
	}
}
 
开发者ID:IOCare,项目名称:cordova-plugin-smartconfig,代码行数:29,代码来源:UDPSocketServer.java

示例3: multicast

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
@ProtoMethod(description = "Enable multicast networking", example = "")
@ProtoMethodParam(params = {"boolean"})
public void multicast(boolean b) {
    WifiManager wifi = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
    if (wifi != null) {
        if (b) {
            wifiLock = wifi.createMulticastLock("mylock");
            wifiLock.acquire();
        } else {
            wifiLock.release();
        }
    }
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:14,代码来源:PNetwork.java

示例4: MulticastEnabler

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
MulticastEnabler(boolean b) {
    WifiManager wifi = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
    if (wifi != null) {
        if (b) {
            wifiLock = wifi.createMulticastLock("mylock");
            wifiLock.acquire();
            getAppRunner().whatIsRunning.add(this);

        } else {
            wifiLock.release();
        }
    }
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:14,代码来源:PNetwork.java

示例5: init

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
public void init(Context activity, MDnsCallbackInterface callback) {
	this.activity = activity;
	this.callback = callback;
	isDiscovering = false;
	wm = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE);
	multicastLock = wm.createMulticastLock(getClass().getName());
	multicastLock.setReferenceCounted(true);
}
 
开发者ID:hoanglm4,项目名称:RxAndroidTBP,代码行数:9,代码来源:MDnsHelper.java

示例6: onApplicationCreate

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
public void onApplicationCreate(Context context) {
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiManager.MulticastLock multicastLock = wm.createMulticastLock("mydebuginfo");
    multicastLock.acquire();
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:6,代码来源:WifiUtil.java


注:本文中的android.net.wifi.WifiManager.createMulticastLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。