当前位置: 首页>>代码示例>>Java>>正文


Java WifiP2pDeviceList.getDeviceList方法代码示例

本文整理汇总了Java中android.net.wifi.p2p.WifiP2pDeviceList.getDeviceList方法的典型用法代码示例。如果您正苦于以下问题:Java WifiP2pDeviceList.getDeviceList方法的具体用法?Java WifiP2pDeviceList.getDeviceList怎么用?Java WifiP2pDeviceList.getDeviceList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.wifi.p2p.WifiP2pDeviceList的用法示例。


在下文中一共展示了WifiP2pDeviceList.getDeviceList方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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

示例3: 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

示例4: 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

示例5: 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

示例6: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
@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.");
        }
    });
}
 
开发者ID:woodplantation,项目名称:werewolf,代码行数:34,代码来源:PeerListListener.java

示例7: getPeersAsSkyDivers

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
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;
}
 
开发者ID:vaslabs,项目名称:SDC,代码行数:10,代码来源:PeersChangedConnectivityActionResponder.java

示例8: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
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);
   		}
	}	
}
 
开发者ID:andrebask,项目名称:expo-connect,代码行数:12,代码来源:PeersListUpdater.java

示例9: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
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;
    	}
	}	
}
 
开发者ID:andrebask,项目名称:expo-connect,代码行数:13,代码来源:PeersListUpdater.java

示例10: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
@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");
	}
}
 
开发者ID:zzhouj,项目名称:android_opengles,代码行数:14,代码来源:NFGame.java

示例11: onWifiP2pPeersChanged

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
/**
 * Called when the WifiP2pManager notifies the Speaker that new peers are
 * available. This method extracts the actual list of peers from the 
 * intent, creates or retrieves canonical Peer objects for each, and 
 * then adds those peers to the PeerManager.
 *
 * @param context Context passed to onReceive, forwarded to this method.
 * @param intent An intent containing the list of new Wifi Direct devices as
 * an extra.
 */
private void onWifiP2pPeersChanged(Context context, Intent intent) {
  // Temp used merely for readability (avoiding very long line/weird indent).
  Parcelable temp = intent.getParcelableExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST);
  WifiP2pDeviceList peerDevices = (WifiP2pDeviceList) temp;

  boolean foundAnyRangzenPeers = false;

  for (WifiP2pDevice device : peerDevices.getDeviceList()) {
    if (device.deviceName != null && device.deviceName.startsWith(RangzenService.RSVP_PREFIX)) {
      String bluetoothAddress = device.deviceName.replace(RangzenService.RSVP_PREFIX, "");
      Log.i(TAG, "Found Rangzen peer " + device.deviceName + " with address " + bluetoothAddress);
      if (BluetoothSpeaker.looksLikeBluetoothAddress(bluetoothAddress) &&
          !BluetoothSpeaker.isReservedMACAddress(bluetoothAddress)) {
        BluetoothDevice bluetoothDevice = mBluetoothSpeaker.getDevice(bluetoothAddress);

        if (stopwatch.isStarted()) {
          stopwatch.stop();
        }
        float seconds = stopwatch.getNanoTime() / (float)(1000 * 1000 * 1000);
        float ms = stopwatch.getNanoTime() / (float)(1000 * 1000);
        Log.i(TAG, "Discovered a peer " + seconds + " seconds after discoverPeers call.");
        foundAnyRangzenPeers = true;

        if (bluetoothDevice != null) {
          Peer peer = getCanonicalPeerByDevice(bluetoothDevice);
          Log.d(TAG, "Adding peer " + peer);  
          mPeerManager.addPeer(peer);
        } else {
          Log.e(TAG, "Address " + bluetoothAddress + " got a null bluetooth device, not adding as peer.");
        }
      }
      else {
        Log.w(TAG, "Address from peer doesn't look like BT address or is reserved: " + bluetoothAddress);
      }

    }
  }

  // If we found any Rangzen peers, then we stop seeking a wait a while before
  // doing it again, in order to measure the time it takes to find peers.
  if (foundAnyRangzenPeers) {
    stopSeekingPeers();      
    touchLastSeekingTime();  // Touch the last seeking time to wait a while before seeking.
  }
  Log.v(TAG, "P2P peers changed");
}
 
开发者ID:casific,项目名称:murmur,代码行数:57,代码来源:WifiDirectSpeaker.java

示例12: onWifiP2pPeersChanged

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
/**
 * Called when the WifiP2pManager notifies the Speaker that new peers are
 * available. This method extracts the actual list of peers from the 
 * intent, creates or retrieves canonical Peer objects for each, and 
 * then adds those peers to the PeerManager.
 *
 * @param context Context passed to onReceive, forwarded to this method.
 * @param intent An intent containing the list of new Wifi Direct devices as
 * an extra.
 */
private void onWifiP2pPeersChanged(Context context, Intent intent) {
  log.info("WifiDirectSpeaker called onWifiP2pPeersChanged");
    Log.d("peerDebug", "WifiDirectSpeaker called onWifiP2pPeersChanged");
  // Temp used merely for readability (avoiding very long line/weird indent).
  Parcelable temp = intent.getParcelableExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST);
  WifiP2pDeviceList peerDevices = (WifiP2pDeviceList) temp;

  for (WifiP2pDevice device : peerDevices.getDeviceList()) {
    if (device.deviceName != null && device.deviceName.startsWith(MurmurService.RSVP_PREFIX)) {
      String bluetoothAddress = device.deviceName.replace(MurmurService.RSVP_PREFIX, "");
      log.info( "Found Murmur peer " + device.deviceName + " with address " + bluetoothAddress);
        Log.d("peerDebug",  "Found Murmur peer " + device.deviceName + " with address " + bluetoothAddress);
      if (BluetoothSpeaker.looksLikeBluetoothAddress(bluetoothAddress) &&
          !BluetoothSpeaker.isReservedMACAddress(bluetoothAddress)) {
        BluetoothDevice bluetoothDevice = mBluetoothSpeaker.getDevice(bluetoothAddress);
        if (bluetoothDevice != null) {
          Peer peer = getCanonicalPeerByDevice(bluetoothDevice);
          log.debug( "Adding peer " + peer);
            Log.d("peerDebug", "Adding peer " + peer);
          mPeerManager.addPeer(peer);
        } else {
          log.error( "Address " + bluetoothAddress + " got a null bluetooth device, not adding as peer.");
            Log.d("peerDebug",  "Address " + bluetoothAddress + " got a null bluetooth device, not adding as peer.");
        }
      }
      else {
        log.warn( "Address from peer doesn't look like BT address or is reserved: " + bluetoothAddress);
          Log.d("peerDebug", "Address from peer doesn't look like BT address or is reserved: " + bluetoothAddress);
      }
    } else {
        if(device != null){
            log.info( "Found device? "+device);
            Log.d("peerDebug", "Found device? "+device);
        } else {
            log.info( "Got null device");
            Log.d("peerDebug", "Got null device");
        }
    }
  }
  log.info( "P2P peers changed "+peerDevices.getDeviceList().size());
    Log.d("peerDebug", "P2P peers changed "+peerDevices.getDeviceList().size());

    ExchangeHistoryTracker.getInstance().cleanHistory(mPeerManager.getPeers());
}
 
开发者ID:casific,项目名称:murmur,代码行数:55,代码来源:WifiDirectSpeaker.java

示例13: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDeviceList; //导入方法依赖的package包/类
@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);
	  
	  
	  
  }
}
 
开发者ID:n8fr8,项目名称:gilgamesh,代码行数:17,代码来源:WifiController.java


注:本文中的android.net.wifi.p2p.WifiP2pDeviceList.getDeviceList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。