本文整理汇总了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);
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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);
}
示例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();
}