當前位置: 首頁>>代碼示例>>Java>>正文


Java WifiP2pDeviceList類代碼示例

本文整理匯總了Java中android.net.wifi.p2p.WifiP2pDeviceList的典型用法代碼示例。如果您正苦於以下問題:Java WifiP2pDeviceList類的具體用法?Java WifiP2pDeviceList怎麽用?Java WifiP2pDeviceList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WifiP2pDeviceList類屬於android.net.wifi.p2p包,在下文中一共展示了WifiP2pDeviceList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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;
        }
    }
}
 
開發者ID:mDL-ILP,項目名稱:mDL-ILP,代碼行數:26,代碼來源:WiFiDirectConnection.java

示例2: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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();
        }
 
開發者ID:niyueming,項目名稱:WiFiP2PDemo,代碼行數:18,代碼來源:WiFiP2PBroadcastReceiver.java

示例3: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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();

}
 
開發者ID:vaslabs,項目名稱:SDC,代碼行數:23,代碼來源:PeersChangedConnectivityActionResponder.java

示例4: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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;
  }
}
 
開發者ID:named-data-mobile,項目名稱:NFD-android,代碼行數:21,代碼來源:NDNController.java

示例5: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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);
	}

}
 
開發者ID:npmiller,項目名稱:syncarnet,代碼行數:18,代碼來源:PeerList.java

示例6: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:cdelorme,項目名稱:collision-avoidance-warning,代碼行數:28,代碼來源:WifiBroadcastReceiver.java

示例7: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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());
    }
  }
}
 
開發者ID:google,項目名稱:physical-web,代碼行數:20,代碼來源:WifiUrlDeviceDiscoverer.java

示例8: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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);
        }
    }
}
 
開發者ID:tkhduracell,項目名稱:app_syncit,代碼行數:18,代碼來源:PeerToPeerHandler.java

示例9: onReceive

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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();
			}
		}
	});
}
 
開發者ID:wordsaretoys,項目名稱:klammer,代碼行數:25,代碼來源:Peers.java

示例10: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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");
}
 
開發者ID:jphacks,項目名稱:TK_1701,代碼行數:31,代碼來源:WiFiDirectConnector.java

示例11: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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();
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:16,代碼來源:FileTransferService.java

示例12: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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;
    }

}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:15,代碼來源:DeviceListFragment.java

示例13: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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);
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:11,代碼來源:WiFiP2pHelper.java

示例14: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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.
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:8,代碼來源:WifiDirectSpeaker.java

示例15: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //導入依賴的package包/類
@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.
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:9,代碼來源:WifiDirectSpeaker.java


注:本文中的android.net.wifi.p2p.WifiP2pDeviceList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。