Java 类android.net.wifi.p2p.WifiP2pManager.ChannelListener 实例源码

项目:dissertation-project    文件:WifiDirectSdHelper.java   
@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();
    }
}
项目:nfcspy    文件:WiFiP2PManager.java   
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;
    }
}
项目:gilgamesh    文件:WifiController.java   
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);
                 }
             });

}
项目:klammer    文件:Wifi.java   
/**
 * 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();
        }
    });
}