当前位置: 首页>>代码示例>>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;未经允许,请勿转载。