android.net.wifi.WpsInfo Java Examples

The following examples show how to use android.net.wifi.WpsInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WifiP2PServiceImpl.java    From Wifi-Connect with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void connectDevice(WifiP2pDevice wifiP2pDevice) {
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = wifiP2pDevice.deviceAddress;
    config.wps.setup = WpsInfo.PBC;
    config.groupOwnerIntent = 15;
    manager.connect(channel, config, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {}
        @Override
        public void onFailure(int reason) {
            if(wifiP2PConnectionCallback != null) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        wifiP2PConnectionCallback.onPeerConnectionFailure();
                    }
                });
            }
        }
    });
}
 
Example #2
Source File: P2pReceiver.java    From ShareBox with Apache License 2.0 6 votes vote down vote up
public void connect(WifiP2pDevice device)
{
    WifiP2pConfig config=new WifiP2pConfig();

    config.deviceAddress=device.deviceAddress;
    config.wps.setup= WpsInfo.PBC;

    _wifiP2pManager.connect(_channel, config, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {

        }

        @Override
        public void onFailure(int reason) {

        }
    });
}
 
Example #3
Source File: WifiDirectHandler.java    From WiFi-Buddy with MIT License 6 votes vote down vote up
/**
 * 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());
        }
    });
}
 
Example #4
Source File: DeviceListFragment.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
/**
 * 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);

}
 
Example #5
Source File: WifiDisplayController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void updateSettings() {
    final ContentResolver resolver = mContext.getContentResolver();
    mWifiDisplayOnSetting = Settings.Global.getInt(resolver,
            Settings.Global.WIFI_DISPLAY_ON, 0) != 0;
    mWifiDisplayCertMode = Settings.Global.getInt(resolver,
            Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, 0) != 0;

    mWifiDisplayWpsConfig = WpsInfo.INVALID;
    if (mWifiDisplayCertMode) {
        mWifiDisplayWpsConfig = Settings.Global.getInt(resolver,
              Settings.Global.WIFI_DISPLAY_WPS_CONFIG, WpsInfo.INVALID);
    }

    updateWfdEnableState();
}
 
Example #6
Source File: P2pManager.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
public void connect(WifiP2pDevice device,WifiP2pManager.ActionListener listener)
{
    WifiP2pConfig config=new WifiP2pConfig();

    config.deviceAddress=device.deviceAddress;
    config.wps.setup= WpsInfo.PBC;

    _wifiP2pManager.connect(_channel, config, listener);
}
 
Example #7
Source File: WiFiP2pHelper.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 指定したMACアドレスの機器へ接続を試みる
 * @param remoteMacAddress
 */
public void connect(@NonNull final String remoteMacAddress) {
	if (DEBUG) Log.v(TAG, "connect:remoteMacAddress=" + remoteMacAddress);
	final WifiP2pConfig config = new WifiP2pConfig();
	config.deviceAddress = remoteMacAddress;
	config.wps.setup = WpsInfo.PBC;
	connect(config);
}
 
Example #8
Source File: WiFiP2pHelper.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 指定した機器へ接続を試みる
 * @param device
 */
public void connect(@NonNull final WifiP2pDevice device) {
	if (DEBUG) Log.v(TAG, "connect:device=" + device);
	final WifiP2pConfig config = new WifiP2pConfig();
	config.deviceAddress = device.deviceAddress;
	config.wps.setup = WpsInfo.PBC;
	connect(config);
}
 
Example #9
Source File: PeerActivity.java    From android-p2p with MIT License 5 votes vote down vote up
private void connectPeer(WifiP2pDevice peer) {
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = peer.deviceAddress;
    config.wps.setup = WpsInfo.PBC;
    this.Application.P2pHandler.Manager.connect(this.Application.P2pHandler.Channel, config, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            Toast.makeText(PeerActivity.this, "Connecting to peer ...", Toast.LENGTH_SHORT).show();
        }
        @Override
        public void onFailure(int reason) {
            Toast.makeText(PeerActivity.this, "Peer connection failed with code " + Integer.toString(reason), Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example #10
Source File: WifiDirectManager.java    From ShareBox with Apache License 2.0 4 votes vote down vote up
public void wifiP2pConnect() {
	ALog.i(TAG, "wifiP2pConnect mRemoteWifiP2pDeviceAddress:" + mRemoteWifiP2pDeviceAddress);
	WifiP2pConfig config = new WifiP2pConfig();
	config.deviceAddress = mRemoteWifiP2pDeviceAddress;
	config.wps.setup = WpsInfo.PBC;
}