當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。