android.net.wifi.p2p.WifiP2pDeviceList Java Examples

The following examples show how to use android.net.wifi.p2p.WifiP2pDeviceList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WifiDisplayController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void requestPeers() {
    mWifiP2pManager.requestPeers(mWifiP2pChannel, new PeerListListener() {
        @Override
        public void onPeersAvailable(WifiP2pDeviceList peers) {
            if (DEBUG) {
                Slog.d(TAG, "Received list of peers.");
            }

            mAvailableWifiDisplayPeers.clear();
            for (WifiP2pDevice device : peers.getDeviceList()) {
                if (DEBUG) {
                    Slog.d(TAG, "  " + describeWifiP2pDevice(device));
                }

                if (isWifiDisplay(device)) {
                    mAvailableWifiDisplayPeers.add(device);
                }
            }

            if (mDiscoverPeersInProgress) {
                handleScanResults();
            }
        }
    });
}
 
Example #2
Source File: WifiP2PServiceImpl.java    From Wifi-Connect with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void handleOnPeersChangedResponse() {
    manager.requestPeers(channel, new WifiP2pManager.PeerListListener() {
        @Override
        public void onPeersAvailable(final WifiP2pDeviceList wifiP2pDeviceList) {
            if(wifiP2PConnectionCallback != null) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        wifiP2PConnectionCallback.onPeerAvailable(wifiP2pDeviceList);
                    }
                });
            }
        }
    });
}
 
Example #3
Source File: WifiUrlDeviceDiscoverer.java    From physical-web with Apache License 2.0 6 votes vote down vote up
@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());
    }
  }
}
 
Example #4
Source File: DeviceListFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@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");
    }
}
 
Example #5
Source File: DeviceListFragment.java    From Wifi-Connect with Apache License 2.0 5 votes vote down vote up
public void onDeviceAvailable(final WifiP2pDeviceList wifiP2pDeviceList) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if(recyclerView.isEnabled()) {
                progressView.setVisibility(View.GONE);
                emptyView.setVisibility(View.GONE);
                recyclerView.setVisibility(View.VISIBLE);
                swipeRefreshLayout.setVisibility(View.VISIBLE);
                wifiListAdapter.addDevices(new ArrayList<>(wifiP2pDeviceList.getDeviceList()));
                recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(activity, DeviceListFragment.this));
            }
        }
    });
}
 
Example #6
Source File: P2pChatService.java    From android-p2p with MIT License 5 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList deviceList) {
    Collection<WifiP2pDevice> foundDevices = deviceList.getDeviceList();
    boolean devicesRemoved = this.Devices.retainAll(foundDevices);
    boolean devicesAdded = this.Devices.addAll(foundDevices);
    if (devicesRemoved || devicesAdded) {
        this.updateDevices();
    }
}
 
Example #7
Source File: WiFiDirectActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
  mWifiP2pManager.requestPeers(mWifiDirectChannel,
    new WifiP2pManager.PeerListListener() {
      public void onPeersAvailable(WifiP2pDeviceList peers) {
        // TODO Update UI with new list of peers.
      }
    });
}
 
Example #8
Source File: P2pConnect.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
    for(WifiP2pDevice device:peers.getDeviceList())
    {
        Log.i(TAG,device.toString());
    }
    _p2pDeviceList.clear();
    _p2pDeviceList.addAll(peers.getDeviceList());
}
 
Example #9
Source File: WifiDirectHandler.java    From WiFi-Buddy with MIT License 5 votes vote down vote up
/** Constructor **/
public WifiDirectHandler() {
    super(ANDROID_SERVICE_NAME);
    dnsSdTxtRecordMap = new HashMap<>();
    dnsSdServiceMap = new HashMap<>();
    peers = new WifiP2pDeviceList();
}
 
Example #10
Source File: WiFiP2pHelper.java    From libcommon with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: DeviceListFragment.java    From Demo_Public with MIT License 5 votes vote down vote up
@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;
    }
}
 
Example #12
Source File: WifiController.java    From gilgamesh with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {

  Collection<WifiP2pDevice> deviceList = peerList.getDeviceList();

  for (WifiP2pDevice device : deviceList)
  {
	  boolean trusted = false; //not sure how to do this with wifi
	  
 	 if (!GilgaService.mapToNickname(device.deviceAddress).startsWith(mLocalAddressHeader)) //not me
 		mService.processInboundMessage(device.deviceName,device.deviceAddress,trusted);
	  
	  
	  
  }
}
 
Example #13
Source File: WiFiP2PCommand.java    From nfcspy with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
	onFinished(STA_SUCCESS, peers.getDeviceList());
}
 
Example #14
Source File: SenderActivity.java    From Wifi-Connect with Apache License 2.0 4 votes vote down vote up
@Override
public void onPeerAvailable(WifiP2pDeviceList wifiP2pDeviceList) {
    onDeviceAvailable(wifiP2pDeviceList);
}
 
Example #15
Source File: SenderActivity.java    From Wifi-Connect with Apache License 2.0 4 votes vote down vote up
@Override
public void onDeviceAvailable(WifiP2pDeviceList wifiP2pDeviceList) {
    Fragment fragment = getCurrentFragment();
    if(fragment instanceof DeviceListFragment) ((DeviceListFragment)fragment).onDeviceAvailable(wifiP2pDeviceList);
}
 
Example #16
Source File: P2pReceiver.java    From ShareBox with Apache License 2.0 2 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {

}
 
Example #17
Source File: ReceiverActivity.java    From Wifi-Connect with Apache License 2.0 2 votes vote down vote up
@Override
public void onPeerAvailable(WifiP2pDeviceList wifiP2pDeviceList) {

}
 
Example #18
Source File: OnSenderUIListener.java    From Wifi-Connect with Apache License 2.0 votes vote down vote up
void onDeviceAvailable(final WifiP2pDeviceList wifiP2pDeviceList); 
Example #19
Source File: WifiP2PConnectionCallback.java    From Wifi-Connect with Apache License 2.0 votes vote down vote up
void onPeerAvailable(WifiP2pDeviceList wifiP2pDeviceList);