Java 类android.net.wifi.p2p.WifiP2pDeviceList 实例源码

项目:mDL-ILP    文件:WiFiDirectConnection.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList wifiP2pDeviceList) {

    if (!connectionAttemptInProgress.compareAndSet(false, true)) {
        return;
    }

    if (connected.get()) {
        return;
    }

    for (WifiP2pDevice device : wifiP2pDeviceList.getDeviceList()) {
        if (device.deviceAddress.equals(target)) {
            WifiP2pConfig config = new WifiP2pConfig();
            config.deviceAddress = device.deviceAddress;
            config.wps.setup = WpsInfo.PBC;
            config.groupOwnerIntent = 0; // I want the other device to be the group owner (or 'server')

            Log.d(TAG, "Trying to connect to "+device.deviceAddress+" "+device.deviceName+" Owner: "+device.isGroupOwner());

            connect(config);
            break;
        }
    }
}
项目:WiFiP2PDemo    文件:WiFiP2PBroadcastReceiver.java   
@Override
        public void onPeersAvailable(WifiP2pDeviceList peerList) {

            // Out with the old, in with the new.
            MainActivity.peers.clear();
            MainActivity.peers.addAll(peerList.getDeviceList());

            // If an AdapterView is backed by this data, notify it
            // of the change.  For instance, if you have a ListView of available
            // peers, trigger an update.
//            ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
//            if (peers.size() == 0) {
//                Log.d(WiFiDirectActivity.TAG, "No devices found");
//                return;
//            }
            activity.notifyDataSetChanged();
        }
项目:SDC    文件:PeersChangedConnectivityActionResponder.java   
@Override
public void onPeersAvailable( WifiP2pDeviceList peers ) {

        Log.i("onPeersAvailable", "" + peers.getDeviceList().size());
        SkyDivingEnvironment environment = SkyDivingEnvironment.getInstance( );
        if (environment == null)
                return;

        for (String sdKey : previouslyDiscoveredPresence.keySet()) {
                setAbsent(sdKey);
        }
        List<SkyDiver> skydivers = getPeersAsSkyDivers(peers);
        for (SkyDiver skydiver : skydivers) {
                environment.onNewSkydiverInfo(skydiver);
                setPresent(skydiver.getName());


        }

        manageDisconnections();

}
项目:NFD-android    文件:NDNController.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
  Log.d(TAG,
    String.format("Peers available: %d", peerList.getDeviceList().size()));

  discoverdPeers.clear();
  discoverdPeers.addAll(peerList.getDeviceList());

  updateIpPeerMapOfConnectedPeers();
  removeDisconnectedPeersFromIpPeerMapOfConnectedPeers();
  checkConnectionConsistency();

  // If an AdapterView is backed by this data, notify it
  // of the change.  For instance, if you have a ListView of available
  // peers, trigger an update.
  if (discoverdPeers.size() == 0) {
    Log.d(TAG, "No devices found");
    return;
  }
}
项目:syncarnet    文件:PeerList.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
    if (display) {
        peerList.clear();
        peerList.addAll(peers.getDeviceList());
        if (peerList.size() == 0) {
            Toast.makeText(synCarnet, synCarnet.getString(R.string.noPair), Toast.LENGTH_SHORT).show();
        }
        progressDialog = synCarnet.syncService.getProgressDialog();
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
        peerListDialog.setPeerList(peerList);
        synCarnet.syncService.onPeerSelection(peerListDialog);
    }

}
项目:collision-avoidance-warning    文件:WifiBroadcastReceiver.java   
/**
 * Acquire new peers list and connect
 *
 * @param WifiP2pDeviceList peerList of devices!
 */
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList)
{
    // Wipe old list
    // @todo filter connected peers (by address) out of new list
    this.peers.clear();

    // Add new list
    this.peers.addAll(peerList.getDeviceList());

    // Iterate to connect
    for (WifiP2pDevice device : this.peers) {

        // Prepare Config /w Device Address
        WifiP2pConfig wifiP2pConfig = new WifiP2pConfig();
        wifiP2pConfig.deviceAddress = device.deviceAddress;

        // Connect
        // @todo add success/failure handling
        this.wifiP2pManager.connect(this.wifiP2pChannel, wifiP2pConfig, null);
    }
}
项目:physical-web    文件:WifiUrlDeviceDiscoverer.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList list) {
  Log.d(TAG, list.toString());
  for (WifiP2pDevice device : list.getDeviceList()) {
    Utils.WifiDirectInfo info = Utils.parseWifiDirectName(device.deviceName);
    if (info != null) {
      String name = info.title;
      int port = info.port;
      reportUrlDevice(createUrlDeviceBuilder("WifiDirect" + name,
          device.deviceAddress + ":" + port)
        .setWifiAddress(device.deviceAddress)
        .setWifiPort(port)
        .setTitle(name)
        .setDescription("")
        .setDeviceType(Utils.WIFI_DIRECT_DEVICE_TYPE)
        .build());
    }
  }
}
项目:app_syncit    文件:PeerToPeerHandler.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
    final Collection<WifiP2pDevice> deviceList = peers.getDeviceList();
    final int nbrPeers = deviceList.size();

    boolean isEqual = mPeers.containsAll(deviceList) && deviceList.containsAll(mPeers);

    Log.d(LOG_TAG, "PeerList: size=" + nbrPeers + ", wasUpdated?=" + !isEqual);

    if (!isEqual) {
        mPeers.clear();
        mPeers.addAll(deviceList);
        if (mWifiP2pUiListener != null) {
            mWifiP2pUiListener.updatePeerList(mPeers);
        }
    }
}
项目:klammer    文件:Peers.java   
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Logg.d(TAG, "received action " + action);
    // request list of peers
    wifi.getManager().requestPeers(
            wifi.getChannel(), new PeerListListener() {
        @Override
        public void onPeersAvailable(WifiP2pDeviceList peers) {
            // retreive list of devices
            devices.clear();
            for (WifiP2pDevice device : peers.getDeviceList()) {
                devices.add(device);
            }
            onChange();

            // if number of peers drops to zero
            if (devices.size() == 0) {
                // check again
                discover();
            }
        }
    });
}
项目:TK_1701    文件:WiFiDirectConnector.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    //Log.d(TAG,peers.toString());

    // if Device on Inviting or Connected, terminate.
    if (onConnecting || wfd.status.p2p_status.equals("Connected") || wfd.status.p2p_status.equals("Invited")){
        return;
    }

    // Search Opponent Device in Peer List
    for(int i=0; i<peers.size(); ++i){
        if (peers.get(i).deviceName.equals(wfd.getOpponentID())){
            onConnecting = true;

            WifiP2pDevice device = peers.get(i);
            WifiP2pConfig config = new WifiP2pConfig();
            config.deviceAddress = device.deviceAddress;
            config.wps.setup = WpsInfo.PBC;

            Log.d(TAG,"connect challenge");
            wfd.connect(config);
            return;
        }
    }

    // Can't Found Opponent Device
    Log.d(TAG,"can't found device");
}
项目:aos-FileCoreLibrary    文件:FileTransferService.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
    List<Device> peerList = new ArrayList<Device>();
    for (WifiP2pDevice peer : peers.getDeviceList()){
        peerList.add(new Device(peer.deviceName, peer.deviceAddress, peer.status));
    }
    // Broadcast to all clients the new value.
    final int N = mCallbacks.beginBroadcast();
    for (int i=0; i<N; i++) {
        try {
            mCallbacks.getBroadcastItem(i).updatePeersList(peerList);
        } catch (RemoteException e) {}
    }
    mCallbacks.finishBroadcast();
}
项目:buildAPKsSamples    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:libcommon    文件:WiFiP2pHelper.java   
@Override
public void onPeersAvailable(final WifiP2pDeviceList peers) {
    if (DEBUG) Log.v(TAG, "onPeersAvailable:peers=" + peers);
    final Collection<WifiP2pDevice> devices = peers.getDeviceList();
    synchronized (mAvailableDevices) {
        mAvailableDevices.clear();
        mAvailableDevices.addAll(devices);
    }
    callOnUpdateDevices(mAvailableDevices);
}
项目:murmur    文件:WifiDirectSpeaker.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerDevices) {
  Log.d(TAG, "New wifi direct peer devices available" + peerDevices);
  // Actual handling of these peers is performed directly when the
  // peers changed event is raised, rather than indirectly here after
  // a request an a callback.
}
项目:murmur    文件:WifiDirectSpeaker.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerDevices) {
  log.debug( "New wifi direct peer devices available" + peerDevices);
    Log.d("peerDebug", "New wifi direct peer devices available" + peerDevices);
  // Actual handling of these peers is performed directly when the
  // peers changed event is raised, rather than indirectly here after
  // a request an a callback.
}
项目:Demo_Public    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peersList) {
    if(progressDialog != null && progressDialog.isShowing())
        progressDialog.dismiss();
    peers.clear();
    peers.addAll(peersList.getDeviceList());
    ((WiFiPeerListAdapter)getListAdapter()).notifyDataSetChanged();
    if(peers.size() == 0){
        Log.e(WiFiDirectActivity.TAG, "the peers size is 0");
        return;
    }
}
项目:WiFi-Buddy    文件:WifiDirectHandler.java   
/** Constructor **/
public WifiDirectHandler() {
    super(ANDROID_SERVICE_NAME);
    dnsSdTxtRecordMap = new HashMap<>();
    dnsSdServiceMap = new HashMap<>();
    peers = new WifiP2pDeviceList();
}
项目:Nucleus    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:Practice    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:Practice    文件:WifiP2pHelper.java   
@Override
    public void onPeersAvailable(WifiP2pDeviceList peerList) {
        // TODO Auto-generated method stub
        WifiP2pDevice device;
        deviceList.clear();
        deviceList.addAll(peerList.getDeviceList());
        for(int i=0; i<deviceList.size(); i++) {
            WifiP2pDevice dd = deviceList.get(i);
//            LogUtils.i(WifiP2pHelper.TAG, dd + "---->addr="+dd.deviceAddress);
        }
        handler.sendEmptyMessage(WIFIP2P_DEVICE_LIST_CHANGED);
    }
项目:Practice    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:Practice    文件:WifiP2pHelper.java   
@Override
    public void onPeersAvailable(WifiP2pDeviceList peerList) {
        // TODO Auto-generated method stub
        WifiP2pDevice device;
        deviceList.clear();
        deviceList.addAll(peerList.getDeviceList());
        for(int i=0; i<deviceList.size(); i++) {
            WifiP2pDevice dd = deviceList.get(i);
//            LogUtils.i(WifiP2pHelper.TAG, dd + "---->addr="+dd.deviceAddress);
        }
        handler.sendEmptyMessage(WIFIP2P_DEVICE_LIST_CHANGED);
    }
项目:Practice    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:Practice    文件:WifiP2pHelper.java   
@Override
    public void onPeersAvailable(WifiP2pDeviceList peerList) {
        // TODO Auto-generated method stub
        WifiP2pDevice device;
        deviceList.clear();
        deviceList.addAll(peerList.getDeviceList());
        for(int i=0; i<deviceList.size(); i++) {
            WifiP2pDevice dd = deviceList.get(i);
//            LogUtils.i(WifiP2pHelper.TAG, dd + "---->addr="+dd.deviceAddress);
        }
        handler.sendEmptyMessage(WIFIP2P_DEVICE_LIST_CHANGED);
    }
项目:Practice    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:Practice    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:werewolf    文件:PeerListListener.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    boolean flag = false;
    WifiP2pConfig config = new WifiP2pConfig();

    for (WifiP2pDevice peer : peerList.getDeviceList()) {
        if (peer.deviceAddress.equals(client.getGroupOwnerMacAddress())) {
            config.deviceAddress = peer.deviceAddress;
            flag = true;
            break;
        }
    }
    if (!flag) {
        client.getOutcomeBroadcastSender().serviceStoppedShowDialogFinishActivity("Keine Lobby gefunden.");
        client.stopSelf();
        return;
    }

    config.wps.setup = WpsInfo.PBC;

    client.getmManager().connect(client.getmChannel(), config, new WifiP2pManager.ActionListener() {

        @Override
        public void onSuccess() {
            // WiFiDirectBroadcastReceiver will notify us. Ignore for now.
        }

        @Override
        public void onFailure(int reason) {
            Log.v("ClientPeerListListener", "Connect failed. Retry.");
        }
    });
}
项目:susurrus-android-app    文件:WifiDirectBroadcastReceiver.java   
@Override
/**
 * Async callback.
 * Is called after peer scan was completed.
 */
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    /*Log.d(LOG_TAG, "onPeersAvailable");

    // Out with the old, in with the new.
    peers.clear();
    peers.addAll(peerList.getDeviceList());

    if (peers.size() == 0) {
        Log.d(LOG_TAG, "No devices found");
        return;
    }
    else {
        Log.d(LOG_TAG, "Devices found: " + peers.size());

        for(int i = 0; i < peers.size(); i++) {
            WifiP2pDevice currentDevice = (WifiP2pDevice) peers.get(i);
            String deviceName = currentDevice.deviceName;

            Log.d(LOG_TAG, "DeviceName: " + deviceName);
        }
    }*/
}
项目:SDC    文件:PeersChangedConnectivityActionResponder.java   
private List<SkyDiver> getPeersAsSkyDivers(WifiP2pDeviceList peers) {
        Collection<WifiP2pDevice> devices = peers.getDeviceList();
        List<SkyDiver> skydivers = new ArrayList<SkyDiver>();
        for (WifiP2pDevice device : devices) {
                skydivers.add( SkyDiver.valueOf(device) );

        }
        return skydivers;
}
项目:Scatterbrain    文件:ScatterPeerListener.java   
private String dumpStack () {
    String result = "";
    for(WifiP2pDeviceList dev : peerstack) {
        result = result + dev.toString() + "\n";
    }
    return result;
}
项目:Scatterbrain    文件:ScatterPeerListener.java   
public WifiP2pDeviceList getPeers() {
    haspeers = false;
    if(peerstack.size() > 0) {
        WifiP2pDeviceList tmp = peerstack.get(0);
        peerstack.remove(0);
        return tmp;
    }
    else {
        return new WifiP2pDeviceList();
    }
}
项目:AndroidSideLoading    文件:DevicesListFragment.java   
public void onPeersAvailable(WifiP2pDeviceList peerList) {

        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
        peers.clear();
        peers.addAll(peerList.getDeviceList());
        listAdapter.notifyDataSetChanged();
        if (peers.size() == 0) {
            Log.d(WiFiDirectActivity.TAG, "No devices found");
            return;
        }

    }
项目:Blaubot    文件:BlaubotWifiP2PBroadcastReceiver.java   
protected void notify_list_of_peers_changed(final WifiP2pDeviceList peers) {
    executorService.execute(new Runnable() {
        @Override
        public void run() {
            for (IBlaubotWifiDirectEventListener listener : eventListeners) {
                listener.onListOfPeersChanged(peers);
            }
        }
    });
}
项目:expo-connect    文件:PeersListUpdater.java   
public void onPeersAvailable(WifiP2pDeviceList peers) {
    ArrayList<WifiP2pDevice> devices = new ArrayList<WifiP2pDevice>(peers.getDeviceList());

    for (WifiP2pDevice device : devices) {
        if (!connectedDevices.contains(device.deviceAddress)){
            Log.d(ConnectService.TAG, "Connecting to " + device.toString());
            context.connect(device.deviceAddress);
            connectedDevices.add(device.deviceAddress);
        }
    }   
}
项目:expo-connect    文件:PeersListUpdater.java   
public void onPeersAvailable(WifiP2pDeviceList peers) {
    ArrayList<WifiP2pDevice> devices = new ArrayList<WifiP2pDevice>(peers.getDeviceList());

    for (WifiP2pDevice device : devices) {
        if (device.deviceAddress.equals(StartActivity.ScreenMAC)){
            Log.d(StartActivity.TAG, "Screen detected");
            ((TextView) context.findViewById(R.id.screenSearchText)).setText(R.string.connectionProgress);
            context.connect();    
            break;
        }
    }   
}
项目:android_opengles    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(WiFiDirectActivity.TAG, "No devices found");
        return;
    }

}
项目:android_opengles    文件:NFGame.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
    this.peers.clear();
    for (WifiP2pDevice peer : peers.getDeviceList()) {
        this.peers.add(peer);
        Log.d(TAG, "peer = " + peer);
    }
    mergeServicePeers();
    onNFGameNotify();
    if (this.peers.size() == 0) {
        Log.d(TAG, "no peers");
    }
}
项目:SPF    文件:WifiDirectMiddleware.java   
public void onPeerListChanged() {
    mManager.requestPeers(mChannel, new PeerListListener() {

        @Override
        public void onPeersAvailable(WifiP2pDeviceList peers) {
            Collection<WifiP2pDevice> peersCollection = peers.getDeviceList();
            updatePeerList(peersCollection);
        }
    });
}
项目:commcare-android    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    Log.d(TAG, "onPeersAvailable");
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter)getListAdapter()).notifyDataSetChanged();

    if (peers.size() == 0) {
        Log.d(TAG, "No devices found");
    }
}
项目:wifi_p2p    文件:DeviceListFragment.java   
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    peers.clear();
    peers.addAll(peerList.getDeviceList());
    ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
    if (peers.size() == 0) {
        Log.d(MainActivity.TAG, "No devices found");
        return;
    }

}