Java Code Examples for android.net.wifi.p2p.WifiP2pManager#ActionListener

The following examples show how to use android.net.wifi.p2p.WifiP2pManager#ActionListener . These examples are extracted from open source projects. 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 Project: libcommon   File: WiFiP2pHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 切断する
 */
protected void internalDisconnect(final WifiP2pManager.ActionListener listener) {
	if (DEBUG) Log.v(TAG, "internalDisconnect:");
	if (mWifiP2pManager != null) {
		if ((mWifiP2pDevice == null)
			|| (mWifiP2pDevice.status == WifiP2pDevice.CONNECTED)) {
			// 接続されていないか、既に接続済みの時
			if (mChannel != null) {
				mWifiP2pManager.removeGroup(mChannel, listener);
			}
		} else if (mWifiP2pDevice.status == WifiP2pDevice.AVAILABLE
			|| mWifiP2pDevice.status == WifiP2pDevice.INVITED) {

			// ネゴシエーション中の時
			mWifiP2pManager.cancelConnect(mChannel, listener);
		}
	}
}
 
Example 2
Source Project: Salut   File: Salut.java    License: MIT License 6 votes vote down vote up
protected void forceDisconnect() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        WifiP2pManager.ActionListener doNothing = new WifiP2pManager.ActionListener() {
            @Override
            public void onSuccess() {

            }

            @Override
            public void onFailure(int reason) {

            }
        };

        stopServiceDiscovery(false);
        manager.cancelConnect(channel, doNothing);
        manager.clearLocalServices(channel, doNothing);
        manager.clearServiceRequests(channel, doNothing);
        manager.stopPeerDiscovery(channel, doNothing);
    }
}
 
Example 3
Source Project: ShareBox   File: P2pManager.java    License: 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 4
Source Project: ShareBox   File: P2pManager.java    License: Apache License 2.0 4 votes vote down vote up
public void discoverPeers(WifiP2pManager.ActionListener listener)
{
    _wifiP2pManager.discoverPeers(_channel, listener);
}