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


Java WifiP2pConfig类代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:26,代码来源:WiFiDirectConnection.java

示例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();
        }
    });
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:17,代码来源:WiFiDirectConnection.java

示例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);
        }
    });
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:17,代码来源:WiFiDirect.java

示例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) {

        }
    });

}
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:21,代码来源:WifiP2pSender.java

示例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();
        }
    });
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:17,代码来源:WiFiDirectActivity.java

示例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");
	}
}
 
开发者ID:saki4510t,项目名称:libcommon,代码行数:23,代码来源:WiFiP2pHelper.java

示例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());
        }
    });
}
 
开发者ID:Crash-Test-Buddies,项目名称:WiFi-Buddy,代码行数:26,代码来源:WifiDirectHandler.java

示例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();
        }
    });
}
 
开发者ID:TheAndroidApp,项目名称:Nucleus,代码行数:18,代码来源:WiFiDirectActivity.java

示例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();
        }
    });
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:17,代码来源:WiFiDirectActivity.java

示例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();
        }
    });
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:18,代码来源:WiFiDirectActivity.java

示例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();
        }
    });
}
 
开发者ID:prgpascal,项目名称:android-qr-data-transfer,代码行数:29,代码来源:TransferActivity.java

示例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***/
}
 
开发者ID:pranay22,项目名称:Audio-based-probing-of-the-environment,代码行数:22,代码来源:WifiClient.java

示例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");
        }
    });
}
 
开发者ID:ritave,项目名称:RevolutionStarbucks,代码行数:20,代码来源:MainActivity.java

示例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);
        }
    });
}
 
开发者ID:deshi-basara,项目名称:susurrus-android-app,代码行数:30,代码来源:WifiDirectService.java

示例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);
    }
  });
}
 
开发者ID:named-data-mobile,项目名称:NFD-android,代码行数:21,代码来源:NDNController.java


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