WifiP2pManager discoverPeers - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WifiP2pManager discoverPeers method.

This code example shows how to use the following methods:discoverPeers, requestPeers, stopPeerDiscovery, getClass
		} 
	} 
 
	@SuppressLint({ "NewApi", "NewApi" }) 
	public void discover() { 
		mWifiP2pManager.discoverPeers(channel, null);
	} 
 
	private void setDeviceName(WifiP2pManager manager, Channel channel,
			String name, ActionListener listener) {
		try { 
			Method method = manager.getClass().getMethod("setDeviceName",
					Channel.class, String.class, ActionListener.class);
			method.invoke(manager, channel, name, listener);
		} catch (Exception e) {
			Log.e(TAG, "setDeviceName fail: " + e);
		} 
	} 
 
	/** 

4
CodeRank
This code example shows how to use the following methods:discoverPeers
		Toast.makeText(this, "Failed to detect peers. Retrying...", Toast.LENGTH_SHORT).show();
		mHandler.postDelayed(new Runnable() {
 
			@Override 
			public void run() { 
				mManager.discoverPeers(mChannel, MainActivity.this);
			} 
			 
		},5000); 
	} 
 
	@Override 
	public void onSuccess() { 
		// The onSuccess() method only notifies you that the discovery process succeeded and 
		// does not provide any information about the actual peers that it discovered, if any.		 
	} 
	 
	// Step 6b: Discovering peers. If the discovery process succeeds and detects peers,  
	//   the system broadcasts the WIFI_P2P_PEERS_CHANGED_ACTION intent, which you can  
	//   listen for in a broadcast receiver to obtain a list of peers. When your application  
4
CodeRank
This code example shows how to use the following methods:discoverPeers
    } 
     
    //called when send button is clicked 
	public void onClick(View v) {
		if(isWifiP2pEnabled) {
			manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
		 
				public void onFailure(int reason) {
					Log.d(ECnETActivity.TAG, "Peers discover failed: " + reason);
					Toast.makeText(ECnETActivity.this, "Discovery Failed : " + reason, Toast.LENGTH_SHORT).show();
					 
				} 
		 
				public void onSuccess() { 
					Log.d(ECnETActivity.TAG, "Disovering peers initiated...");
					 
				} 
				 
			}); 
			 
4
CodeRank
This code example shows how to use the following methods:discoverPeers
     */ 
    @Override 
    protected void onResume() { 
        super.onResume(); 
 
        mManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() {
 
            @Override 
            public void onSuccess() { 
                Toast.makeText(getApplicationContext(), "Discovery Initiated",
                        Toast.LENGTH_SHORT).show();
            } 
 
            @Override 
            public void onFailure(int reasonCode) {
                Toast.makeText(getApplicationContext(),
                        "Discovery Failed : " + getDiscoveryFailureReasonCode(reasonCode),
                        Toast.LENGTH_SHORT).show();
            } 
        }); 
4
CodeRank
discoverPeers Method Overview
Initiate peer discovery.
See Code Examples for other Android WifiP2pManager Methods: