예제 #1
0
        protected override void OnResume()
        {
            base.OnResume();

            // Setup the receivers for the service's results
            IntentFilter initIntentFilter = new IntentFilter(ServiceAction.INIT.ToString());

            initActivityReceiver = new InitActivityReceiver();
            // Registers the receiver and its intent filters
            RegisterReceiver(initActivityReceiver, initIntentFilter);

            // Setup the connection receiver
            IntentFilter connectIntentFilter = new IntentFilter(ServiceAction.CONNECT.ToString());

            connectActivityReceiver = new ConnectActivityReceiver();
            // Registers the receiver and its intent filters
            RegisterReceiver(connectActivityReceiver, connectIntentFilter);

            // Setup the message sent receiver
            IntentFilter messageIntentFilter = new IntentFilter(ServiceAction.SENDMESSAGE.ToString());

            messageActivityReceiver = new MesssageActivityReceiver();
            // Registers the receiver and its intent filters
            RegisterReceiver(messageActivityReceiver, messageIntentFilter);

            // Starts the IntentService and connects
            Intent mServiceIntent = new Intent(this, typeof(BackgroundService));

            mServiceIntent.PutExtra(ServiceMessage.JID, jid);
            mServiceIntent.PutExtra(ServiceMessage.PASSWORD, password);
            mServiceIntent.SetAction(ServiceAction.INIT.ToString());
            StartService(mServiceIntent);

            Utils.SetConnectionAlarm(this);
        }
예제 #2
0
        protected override void OnResume()
        {
            base.OnResume();

            // Setup the receivers for the service's results
            IntentFilter initIntentFilter = new IntentFilter(ServiceAction.INIT.ToString());
            initActivityReceiver = new InitActivityReceiver();
            // Registers the receiver and its intent filters
            RegisterReceiver(initActivityReceiver, initIntentFilter);

            // Setup the connection receiver
            IntentFilter connectIntentFilter = new IntentFilter(ServiceAction.CONNECT.ToString());
            connectActivityReceiver = new ConnectActivityReceiver();
            // Registers the receiver and its intent filters
            RegisterReceiver(connectActivityReceiver, connectIntentFilter);

            // Setup the message sent receiver
            IntentFilter messageIntentFilter = new IntentFilter(ServiceAction.SENDMESSAGE.ToString());
            messageActivityReceiver = new MesssageActivityReceiver();
            // Registers the receiver and its intent filters
            RegisterReceiver(messageActivityReceiver, messageIntentFilter);

            // Starts the IntentService and connects
            Intent mServiceIntent = new Intent(this, typeof(BackgroundService));
            mServiceIntent.PutExtra(ServiceMessage.JID, jid);
            mServiceIntent.PutExtra(ServiceMessage.PASSWORD, password);
            mServiceIntent.SetAction(ServiceAction.INIT.ToString());
            StartService(mServiceIntent);

            Utils.SetConnectionAlarm(this);
        }