/// <summary>
 /// ctor
 /// </summary>
 /// <param name="manager">WifiP2pManager system service</param>
 /// <param name="channel">Wifi p2p channel</param>
 /// <param name="activity">activity associated with the receiver</param>
 public WiFiDirectBroadcastReceiver(WifiP2pManager manager, WifiP2pManager.Channel channel,
                                    WiFiDirectActivity activity)
 {
     _manager = manager;
     _channel = channel;
     _activity = activity;
 }
示例#2
0
 public void SetManager(WifiP2pManager manager, WifiP2pManager.Channel channel, PeerListListener peerListListener)
 {
     // Maybe the receiver should only use events instead.
     _manager = manager;
     _channel = channel;
     _peerListListener = peerListListener;            
 }
示例#3
0
        public static void Initialize(Context ctx)
        {
            P2PManager.ctx = ctx;

            if (intentFilter == null)
            {
                intentFilter = new IntentFilter();

                intentFilter.AddAction(WifiP2pManager.WifiP2pStateChangedAction);
                intentFilter.AddAction(WifiP2pManager.WifiP2pPeersChangedAction);
                intentFilter.AddAction(WifiP2pManager.WifiP2pConnectionChangedAction);
                intentFilter.AddAction(WifiP2pManager.WifiP2pThisDeviceChangedAction);
            }
            if (manager == null)
            {
                manager = (WifiP2pManager)ctx.GetSystemService(Context.WifiP2pService);
                channel = manager.Initialize(ctx, ctx.MainLooper, null);
            }
            if (receiver == null)
            {
                receiver = new WiFiDirectBroadcastReceiver(manager, channel);
            }

            ctx.RegisterReceiver(receiver, intentFilter);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            _intentFilter.AddAction(WifiP2pManager.WifiP2pStateChangedAction);
            _intentFilter.AddAction(WifiP2pManager.WifiP2pPeersChangedAction);
            _intentFilter.AddAction(WifiP2pManager.WifiP2pConnectionChangedAction);
            _intentFilter.AddAction(WifiP2pManager.WifiP2pThisDeviceChangedAction);

            _manager = (WifiP2pManager) GetSystemService(WifiP2pService);
            _channel = _manager.Initialize(this, MainLooper, null);
        }
示例#5
0
        private void SetupWifiDirect()
        {
            _intentFilter = new IntentFilter();
            _intentFilter.AddAction(WifiP2pManager.WifiP2pStateChangedAction);
            _intentFilter.AddAction(WifiP2pManager.WifiP2pPeersChangedAction);
            _intentFilter.AddAction(WifiP2pManager.WifiP2pConnectionChangedAction);
            _intentFilter.AddAction(WifiP2pManager.WifiP2pThisDeviceChangedAction);

            _actionListener = new ActionListener();
            _peerListListener = new PeerListListener();
            _wifiManager = (WifiP2pManager)SessionsApplication.Context.GetSystemService(Context.WifiP2pService);
            _wifiChannel = _wifiManager.Initialize(SessionsApplication.Context, SessionsApplication.Context.MainLooper, null);
            _wifiDirectReceiver = new WifiDirectReceiver();
            _wifiDirectReceiver.SetManager(_wifiManager, _wifiChannel, _peerListListener);
            SessionsApplication.Context.RegisterReceiver(_wifiDirectReceiver, _intentFilter);
        }
 public WiFiDirectBroadcastReceiver(WifiP2pManager manager, WifiP2pManager.Channel channel)
 {
     this.manager = manager;
     this.channel = channel;
 }