本文整理汇总了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;
}
}
}
示例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());
}
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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.");
}
});
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
}
示例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");
}
}
示例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");
}
示例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());
}
示例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);
}
}