Code example for WifiP2pManager

Methods: initialize

1
        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() {