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