Java Code Examples for android.net.wifi.p2p.WifiP2pDeviceList

The following examples show how to use android.net.wifi.p2p.WifiP2pDeviceList. These examples are extracted from open source projects. 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 Project: android_9.0.0_r45   Source File: WifiDisplayController.java    License: 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 Project: Wifi-Connect   Source File: WifiP2PServiceImpl.java    License: 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 Project: physical-web   Source File: WifiUrlDeviceDiscoverer.java    License: 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 Project: Wifi-Connect   Source File: DeviceListFragment.java    License: 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 5
@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 6
Source Project: ShareBox   Source File: P2pConnect.java    License: 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 7
Source Project: libcommon   Source File: WiFiP2pHelper.java    License: 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 8
Source Project: Demo_Public   Source File: DeviceListFragment.java    License: 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 9
Source Project: WiFi-Buddy   Source File: WifiDirectHandler.java    License: 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 Project: android-p2p   Source File: P2pChatService.java    License: 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 11
Source Project: commcare-android   Source File: DeviceListFragment.java    License: 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 12
Source Project: Wifi-Connect   Source File: SenderActivity.java    License: 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 13
Source Project: Wifi-Connect   Source File: SenderActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onPeerAvailable(WifiP2pDeviceList wifiP2pDeviceList) {
    onDeviceAvailable(wifiP2pDeviceList);
}
 
Example 14
Source Project: nfcspy   Source File: WiFiP2PCommand.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {
	onFinished(STA_SUCCESS, peers.getDeviceList());
}
 
Example 15
Source Project: gilgamesh   Source File: WifiController.java    License: 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 16
Source Project: Wifi-Connect   Source File: ReceiverActivity.java    License: Apache License 2.0 2 votes vote down vote up
@Override
public void onPeerAvailable(WifiP2pDeviceList wifiP2pDeviceList) {

}
 
Example 17
Source Project: ShareBox   Source File: P2pReceiver.java    License: Apache License 2.0 2 votes vote down vote up
@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {

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