本文整理汇总了Java中android.net.wifi.WpsInfo类的典型用法代码示例。如果您正苦于以下问题:Java WpsInfo类的具体用法?Java WpsInfo怎么用?Java WpsInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WpsInfo类属于android.net.wifi包,在下文中一共展示了WpsInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPeersAvailable
import android.net.wifi.WpsInfo; //导入依赖的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: connectToPeer
import android.net.wifi.WpsInfo; //导入依赖的package包/类
private void connectToPeer (WifiP2pDevice device)
{
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
}
});
}
示例3: initiateConnectToService
import android.net.wifi.WpsInfo; //导入依赖的package包/类
/**
* Initiates a connection to a service
* @param service The service to connect to
*/
public void initiateConnectToService(DnsSdService service) {
// Device info of peer to connect to
WifiP2pConfig wifiP2pConfig = new WifiP2pConfig();
wifiP2pConfig.deviceAddress = service.getSrcDevice().deviceAddress;
wifiP2pConfig.wps.setup = WpsInfo.PBC;
// Starts a peer-to-peer connection with a device with the specified configuration
wifiP2pManager.connect(channel, wifiP2pConfig, new WifiP2pManager.ActionListener() {
// The ActionListener only notifies that initiation of connection has succeeded or failed
@Override
public void onSuccess() {
Log.i(TAG, "Initiating connection to service");
}
@Override
public void onFailure(int reason) {
Log.e(TAG, "Failure initiating connection to service: " + FailureReason.fromInteger(reason).toString());
}
});
}
示例4: connect
import android.net.wifi.WpsInfo; //导入依赖的package包/类
/**
* Connect to the desired peer.
*
* @param deviceMacAddress the MAC address of the Server peer to connect with.
*/
private void connect(String deviceMacAddress) {
// Create other device config
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = deviceMacAddress;
config.wps.setup = WpsInfo.PBC;
config.groupOwnerIntent = 0; // I want the other device to be the Group Owner !!
// Perform connection
manager.connect(channel, config, new ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
Toast.makeText(TransferActivity.this, R.string.aqrdt_error_connection_failed, Toast.LENGTH_SHORT).show();
// Error during connection to the peer. Force the Activity to be finished.
finishTransmissionWithError();
}
});
}
示例5: connectP2p
import android.net.wifi.WpsInfo; //导入依赖的package包/类
public synchronized void connectP2p(WifiClientP2pService peer) {
Log.d(TAG,"inside connectp2p ");
/***auto device list***/
/***auto device list***/
Log.d(TAG,"device address: "+peer.getDevice().deviceAddress);
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = peer.getDevice().deviceAddress;
config.wps.setup = WpsInfo.PBC;
//Toast.makeText(getApplicationContext(), "Trying to connect with "+config.deviceAddress, Toast.LENGTH_SHORT).show();
if (serviceRequest != null)
manager.removeServiceRequest(channel, serviceRequest,new ActionListener() {
public void onSuccess() { }
public void onFailure(int arg0) { }
});
manager.connect(channel, config, new ActionListener() {
public void onSuccess() { Log.d(TAG,"Connecting to device"); }
public void onFailure(int errorCode) { Log.d(TAG,"failed Connecting to device"); }
});
/***auto device list***/
/***auto device list***/
}
示例6: SendImage
import android.net.wifi.WpsInfo; //导入依赖的package包/类
private void SendImage(WifiP2pDevice device)
{
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
throw new RuntimeException("Oh god damn");
}
});
}
示例7: connectToLocalService
import android.net.wifi.WpsInfo; //导入依赖的package包/类
/**
* Establishes a connection to a local "susurrus"-service.
* @param roomModel
* @param feedbackActivity
*/
public void connectToLocalService(final RoomModel roomModel, final MainActivity feedbackActivity) {
WifiP2pConfig connectionConfig = new WifiP2pConfig();
connectionConfig.deviceAddress = roomModel.getOwnerAddr();
// user connects, don't make him the owner
connectionConfig.groupOwnerIntent = 0;
// connectionConfig.wps.setup = WpsInfo.INVALID;
connectionConfig.wps.setup = WpsInfo.PBC;
wifiDirectManager.connect(wifiDirectChannel, connectionConfig, new WifiP2pManager.
ActionListener() {
@Override
public void onSuccess() {
//feedbackActivity.showRoomJoinFeedbackUpdate(GROUP_CONNECTED);
}
@Override
public void onFailure(int reason) {
Log.d(LOG_TAG, "Connection to room failed: " + reason);
feedbackActivity.showRoomJoinFeedbackUpdate(GROUP_NOT_CONNECTED);
}
});
}
示例8: connect
import android.net.wifi.WpsInfo; //导入依赖的package包/类
public void connect(WifiP2pDevice peerDevice) {
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = peerDevice.deviceAddress;
config.wps.setup = WpsInfo.PBC;
wifiP2pManager.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// onReceive() in WDBroadcastReceiver will receive an intent
}
@Override
public void onFailure(int reason) {
String reasonString = WDBroadcastReceiver
.getWifiP2pManagerMessageFromReasonCode(reason);
Log.e(TAG, "There was an issue with initiating connection reason: " + reasonString);
}
});
}
示例9: Connect
import android.net.wifi.WpsInfo; //导入依赖的package包/类
public void Connect(String address) {
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = address;
config.wps.setup = WpsInfo.PBC;
p2p.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
debug_print("Connecting to service" );
}
@Override
public void onFailure(int errorCode) {
debug_print("Failed connecting to service : " + errorCode);
}
});
}
示例10: onStart
import android.net.wifi.WpsInfo; //导入依赖的package包/类
@Override
protected void onStart() {
/*
* increment timeout bar per second.
*/
mTimer = new Timer(false);
mTimer.schedule(new TimerTask() {
@Override
public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
mTimeoutBar.incrementProgressBy(1);
}
});
}
}, 1000, 1000);
mContext.registerReceiver(mReceiver, mFilter);
WpsInfo wpsConfig = new WpsInfo();
wpsConfig.setup = mWpsSetup;
mWifiManager.startWps(wpsConfig, mWpsListener);
}
示例11: connectToDevice
import android.net.wifi.WpsInfo; //导入依赖的package包/类
private void connectToDevice(WifiP2pDevice dev) {
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = dev.deviceAddress;
config.wps.setup = WpsInfo.PBC;
manager.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
//this gets broadcast to WifiDirectBroadcastReceiver
//here
}
@Override
public void onFailure(int reason) {
Log.e(TAG, "Failed to connect to wifidirect device");
}
});
}
示例12: connect
import android.net.wifi.WpsInfo; //导入依赖的package包/类
private void connect(){
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel",
"Connecting to :" + device.deviceAddress, true, true
// new DialogInterface.OnCancelListener() {
//
// @Override
// public void onCancel(DialogInterface dialog) {
// ((DeviceActionListener) getActivity()).cancelDisconnect();
// }
// }
);
((DevicesListFragment.DeviceActionListener) getActivity()).connect(config);
}
示例13: onListItemClick
import android.net.wifi.WpsInfo; //导入依赖的package包/类
/**
* Initiate a connection with the peer.
*/
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.d(TAG, "onListItemClick");
WifiP2pDevice device = (WifiP2pDevice)getListAdapter().getItem(position);
Log.d(TAG, "device is: " + device.deviceAddress);
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel",
"Connecting to :" + device.deviceAddress, true, true);
((DeviceActionListener)getActivity()).connect(config);
}
示例14: onPeerSelected
import android.net.wifi.WpsInfo; //导入依赖的package包/类
@Override
public void onPeerSelected(WifiP2pDevice device) {
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
synCarnet.syncService.setConnecting(true);
progressDialog = ProgressDialog.show(synCarnet, synCarnet.getString(R.string.backCancel),
synCarnet.getString(R.string.connectingTo) + device.deviceAddress, true, true);
ServiceStatic.setDevice(device.deviceName, device.deviceAddress);
manager.connect(channel, config, new ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
Toast.makeText(synCarnet, synCarnet.getString(R.string.connectFailed),
Toast.LENGTH_SHORT).show();
Log.d(TAG, "Connect failed : "+reason);
}
});
}
示例15: initialiseDnsTxtRecordListener
import android.net.wifi.WpsInfo; //导入依赖的package包/类
private void initialiseDnsTxtRecordListener() {
mDnsTxtRecordListener = new DnsSdTxtRecordListener() {
@Override
public void onDnsSdTxtRecordAvailable(String fullDomainName,
Map<String, String> txtRecordMap, WifiP2pDevice srcDevice) {
if (fullDomainName.contains(SERVICE_INSTANCE)) {
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = srcDevice.deviceAddress;
config.groupOwnerIntent = 0;
config.wps.setup = WpsInfo.PBC;
mP2PManager.connect(mChannel, config, null);
}
}
};
}