本文整理汇总了Java中android.net.wifi.p2p.WifiP2pManager.ChannelListener类的典型用法代码示例。如果您正苦于以下问题:Java ChannelListener类的具体用法?Java ChannelListener怎么用?Java ChannelListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelListener类属于android.net.wifi.p2p.WifiP2pManager包,在下文中一共展示了ChannelListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import android.net.wifi.p2p.WifiP2pManager.ChannelListener; //导入依赖的package包/类
@Override
public void register(final int port, final boolean discover, Context context) {
mP2PManager.initialize(context, context.getMainLooper(), new ChannelListener() {
@Override
public void onChannelDisconnected() {
Log.d(TAG, "Channel disconnected...");
}
});
mService.registerReceiver(mWifiReceiver, mWifiIntentFilter);
final Map<String, String> record = new HashMap<String, String>();
record.put(TXTRECORD_PORT, String.valueOf(port));
mServiceInfo = WifiP2pDnsSdServiceInfo.newInstance(SERVICE_INSTANCE, SERVICE_REG_TYPE, record);
mP2PManager.addLocalService(mChannel, mServiceInfo, mLocalServiceListener);
if (discover) {
discover();
}
}
示例2: init
import android.net.wifi.p2p.WifiP2pManager.ChannelListener; //导入依赖的package包/类
void init(Context ctx, ChannelListener lsn) {
wifip2p = (WifiP2pManager) ctx.getSystemService(WIFI_P2P_SERVICE);
channel = wifip2p.initialize(ctx, ctx.getMainLooper(), lsn);
if (wifip2p != null && channel != null) {
isWifiP2pEnabled = true;
status = STA_P2P_INITED;
} else {
isWifiP2pEnabled = false;
status = STA_P2P_UNINIT;
}
}
示例3: init
import android.net.wifi.p2p.WifiP2pManager.ChannelListener; //导入依赖的package包/类
public void init (GilgaService service)
{
mService = service;
mWifiManager = (WifiP2pManager) mService.getSystemService(Context.WIFI_P2P_SERVICE);
mWifiChannel = mWifiManager.initialize(mService, mService.getMainLooper(), new ChannelListener()
{
@Override
public void onChannelDisconnected() {
Log.d(GilgaService.TAG,"wifi p2p disconnected");
}
});
WifiP2pDnsSdServiceRequest serviceRequest = WifiP2pDnsSdServiceRequest.newInstance();
mWifiManager.addServiceRequest(mWifiChannel,
serviceRequest,
new ActionListener() {
@Override
public void onSuccess() {
// Success!
Log.d(TAG,"SUCCESS: added service request wifi name service");
}
@Override
public void onFailure(int code) {
// Command failed. Check for P2P_UNSUPPORTED, ERROR, or BUSY
Log.d(TAG,"FAILURED: added service request wifi name service: " + code);
}
});
}
示例4: createChannel
import android.net.wifi.p2p.WifiP2pManager.ChannelListener; //导入依赖的package包/类
/**
* attempt to create channel until it's established
*/
protected void createChannel() {
channel = manager.initialize(
context,
context.getMainLooper(),
new ChannelListener() {
@Override
public void onChannelDisconnected() {
Logg.d(TAG, "Lost wifi channel, reconnecting...");
createChannel();
}
});
}