Android WifiP2pConfig - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android WifiP2pConfig class.

This code example shows how to use the following methods:
        mListener = listener;
        mDevice = device;
    } 
 
    public WifiP2pConfig getConfig() {
        WifiP2pConfig config = new WifiP2pConfig();
        config.deviceAddress = mDeviceAddress.getText().toString();
        config.wps = new WpsInfo();
        switch (mWpsSetupIndex) {
            case WPS_PBC:
                config.wps.setup = WpsInfo.PBC;
                break; 
            case WPS_KEYPAD:
                config.wps.setup = WpsInfo.KEYPAD;
                /*config.wps.pin = ((TextView) mView.findViewById(R.id.wps_pin)). 
                        getText().toString();*/ 
                break; 
            case WPS_DISPLAY:
                config.wps.setup = WpsInfo.DISPLAY;
                break; 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    /** 
     * Attempts to initiate a connection to the given device 
     * @param device The device of interest 
     */ 
	public void connectToDevice(WifiP2pDevice device) {
		WifiP2pConfig config = new WifiP2pConfig();
		config.deviceAddress = device.deviceAddress;
		 
		manager.connect(channel, config, new ActionListener() {
			 
			@Override 
			public void onSuccess() { 
                Toast.makeText(getApplicationContext(), "Connected to Device!", Toast.LENGTH_SHORT).show();
                Log.d(MyApplication.this.TAG, "Device Connected!");
                 
                for(OnDeviceConnectedListener listener : deviceConnectedListeners) {
                	listener.onDeviceConnected();
                } 
			} 
			 
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
     * Initiate a connection with the peer. 
     */ 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        WifiP2pDevice device = (WifiP2pDevice) getListAdapter().getItem(position);
        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);
    } 
 
    /** 
     * Array adapter for ListFragment that maintains WifiP2pDevice list. 
     */ 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
   
  /** 
   * Listing 16-23: Requesting a connection to a Wi-Fi Direct peer 
   */ 
  private void connectTo(WifiP2pDevice device) {
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = device.deviceAddress;
 
    wifiP2pManager.connect(wifiDirectChannel, config, actionListener);
  } 
   
  /** 
   * Listing 16-24: Connecting to a Wi-Fi Direct peer 
   */ 
  BroadcastReceiver connectionChangedReceiver = new BroadcastReceiver() {
    @Override 
    public void onReceive(Context context, Intent intent) { 
       
      // Extract the NetworkInfo 
      String extraKey = WifiP2pManager.EXTRA_NETWORK_INFO; 
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
	 *  
	 * @param targetDevice 
	 *            接続先のデバイス 
	 */ 
	public void connect(WifiP2pDevice targetDevice) {
		WifiP2pConfig config = new WifiP2pConfig();
		config.deviceAddress = targetDevice.deviceAddress;
		config.wps.setup = WpsInfo.PBC; // 接続時認証の指定(Push Button Configuration)
 
		mManager.connect(mChannel, config, null);
	} 
 
	/** 
	 * 接続中のPeerから切断する. 
	 */ 
	public void disconnect() { 
		mCallback.onDisconnect();
		mManager.removeGroup(mChannel, null);
	} 
 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
     * Initiate a connection with the peer. 
     */ 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        WifiP2pDevice device = (WifiP2pDevice) getListAdapter().getItem(position);
        WifiP2pConfig config = new WifiP2pConfig();
        config.deviceAddress = device.deviceAddress;
        config.wps.setup = WpsInfo.PBC;
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        } 
        Log.d("Test", "progressDialogConnectingTo");
        progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel",
                "Connecting to :" + device.deviceAddress, true, true);
        ((DeviceActionListener) getActivity()).connect(config);
    } 
 
    /** 
     * Array adapter for ListFragment that maintains WifiP2pDevice list. 
     */ 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
			public void onItemClick(AdapterView<?> adapterView, View arg1,
					int pos, long arg3) {
				String s = (String) listView.getItemAtPosition(pos);
				String deviceDetails = (s.replace("Connect to ", "")).trim();
				String[] devDetails = deviceDetails.split(",");
				WifiP2pConfig config = new WifiP2pConfig();
				config.deviceAddress = devDetails[1];
				config.wps.setup = WpsInfo.PBC;
				manager.connect(channel, config, new ActionListener() {
 
					@Override 
					public void onSuccess() { 
						(Toast.makeText(context, "p2p connect success",
								Toast.LENGTH_SHORT)).show();
					} 
 
					@Override 
					public void onFailure(int reason) {
						(Toast.makeText(context,
								"p2p connect failed:" + reason,
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
	 * be invoked when the connection is established. 
	 *  
	 * @param peer the peer device to connect to. 
	 */ 
	public void connectToPeer(WifiP2pDevice peer) {
		WifiP2pConfig config = new WifiP2pConfig();
		config.deviceAddress = peer.deviceAddress;
		config.wps.setup = WpsInfo.PBC;
		 
		mManager.connect(mChannel, config, new ActionListener() {
			@Override 
			public void onSuccess() { 
				// Let WifiBroadcastReceiver notify us. Ignore it here. 
			} 
			 
			@Override 
			public void onFailure(int reason) {
				// TODO: notify someone. 
			} 
		}); 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
      } 
   } 
 
   public void connect(WifiP2pDevice device)
   { 
      WifiP2pConfig config = new WifiP2pConfig();
 
      if (device != null)
      { 
         config.deviceAddress = device.deviceAddress;
         manager.connect(channel, config, new ActionListener()
         { 
 
            @Override 
            public void onFailure(int reason)
            { 
 
            } 
 
            @Override 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
	@Override 
	public void onItemClick(AdapterView<?> arg0, View view, int position,
			long arg3) {
		ListView list = (ListView) arg0;
		WifiP2pDevice device = (WifiP2pDevice) list.getItemAtPosition(position);
		WifiP2pConfig config = new WifiP2pConfig();
		config.deviceAddress = device.deviceAddress;
 
		manager.connect(mChannel, config, new ActionListener() {
 
			@Override 
			public void onFailure(int arg0) {
				Log.d("director", "connect failed");
 
			} 
 
			@Override 
			public void onSuccess() { 
				Log.d("director", "connect success ");
 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Android WifiP2pConfig Methods: