Android WifiP2pManager - 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 WifiP2pManager class.

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
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: initialize
        mContext = context;
        mCheckBox = checkBox;
 
        mWifiP2pManager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE);
        if (mWifiP2pManager != null) {
            mChannel = mWifiP2pManager.initialize(mContext, mContext.getMainLooper(), null);
            if (mChannel == null) {
                //Failure to set up connection 
                Log.e(TAG, "Failed to set up connection with wifi p2p service");
                mWifiP2pManager = null;
                mCheckBox.setEnabled(false);
            } 
        } else { 
            Log.e(TAG, "mWifiP2pManager is null!");
        } 
        mIntentFilter = new IntentFilter(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
 
    } 
 
    public void resume() { 
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: requestPeers
	} 
 
	private void refreshPeers() { 
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
			Log.i(TAG, "Request peers");
			wifiMgr.requestPeers(channel, discoveryListener);
		} 
	} 
	 
	@Override 
	public void onChannelDisconnected() { 
		Log.e(TAG, "Error Channel disconnected");
	} 
 
	private class WifiReceiver extends BroadcastReceiver {
		 
		@Override 
		public void onReceive(Context context, Intent intent) {
			String action = intent.getAction();
			if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
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: requestPeers
	@Override 
	public void searchForLinks() { 
		peerListener.devices.clear();
		searchingForLinks = true;
		if (manager != null && channel != null) {
			manager.requestPeers(channel, peerListener);
		} 
	} 
	 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	@Override 
	public void haltConnectionDiscovery() { 
		manager.stopPeerDiscovery(channel, null);
		manager.cancelConnect(channel, null);
	} 
 
	 
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: requestPeers
				discoverPeers(); 
			} else { 
				System.out.println("Wifi disabled!");
			} 
		} else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
			mManager.requestPeers(mChannel, myPeerListListener);
		} 
		else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
 
			connectionChanged(intent);
			// Respond to new connection or disconnections 
		} else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
			// Respond to this device's wifi state changing 
		} 
	} 
 
	private void discoverPeers() { 
		mManager.discoverPeers(mChannel,new WifiP2pManager.ActionListener() {
			@Override 
			public void onSuccess() { 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android WifiP2pManager Questions & Answers:

See Code Examples for Android WifiP2pManager Methods: