本文整理汇总了Java中android.net.wifi.p2p.WifiP2pConfig类的典型用法代码示例。如果您正苦于以下问题:Java WifiP2pConfig类的具体用法?Java WifiP2pConfig怎么用?Java WifiP2pConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WifiP2pConfig类属于android.net.wifi.p2p包,在下文中一共展示了WifiP2pConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPeersAvailable
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
public void connect(WifiP2pConfig config) {
manager.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
peerListener.connectionSuccess();
}
@Override
public void onFailure(int reason) {
peerListener.connectionFailure();
Toast.makeText(activity, "Connect failed. Retry.", Toast.LENGTH_SHORT).show();
}
});
}
示例3: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
protected void connect(WifiP2pConfig config) {
toast("みつけた!");
manager.connect(channel, config, new ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
Log.i(TAG,"p2p connect(try) success");
}
@Override
public void onFailure(int reasonCode) {
Log.i(TAG,"p2p connect(try) failure" + reasonCode);
}
});
}
示例4: connectToPeer
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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) {
}
});
}
示例5: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
@Override
public void connect(WifiP2pConfig config) {
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(WiFiDirectActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
示例6: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
/**
* 指定した機器へ接続を試みる
* @param config
* @throws IllegalStateException
*/
public void connect(@NonNull final WifiP2pConfig config) throws IllegalStateException {
if (DEBUG) Log.v(TAG, "connect:config=" + config);
if (mChannel != null) {
mWifiP2pManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
callOnError(new RuntimeException("failed to connect, reason=" + reason));
}
});
} else {
throw new IllegalStateException("not registered");
}
}
示例7: initiateConnectToService
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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());
}
});
}
示例8: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
@Override
public void connect(WifiP2pConfig config) {
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(WiFiDirectActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
示例9: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
@Override
public void connect(WifiP2pConfig config) {
manager.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
Toast.makeText(WiFiDirectActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
示例10: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的package包/类
@Override
public void connect(WifiP2pConfig config) {
manager.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
Toast.makeText(WiFiDirectActivity.this, "连接成功,选择文件发送",
Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int reason) {
Toast.makeText(WiFiDirectActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
示例11: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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();
}
});
}
示例12: connectP2p
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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***/
}
示例13: SendImage
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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");
}
});
}
示例14: connectToLocalService
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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);
}
});
}
示例15: connect
import android.net.wifi.p2p.WifiP2pConfig; //导入依赖的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);
}
});
}