public override void OnStop()
        {
            base.OnStop();

            UnregisterReceiver(gcmReceiver);
            LocalBroadcastManager.GetInstance(this).UnregisterReceiver(receiver);
        }
示例#2
0
        public override void OnPause()
        {
            base.OnPause();
            LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.GetInstance(Context);

            localBroadcastManager.UnregisterReceiver(channelIdUpdateReceiver);
        }
示例#3
0
        /// <summary>
        /// Send the GCM Token to the Voice Activity.
        /// </summary>
        /// <param name="gcmToken"> The new token. </param>
        private void sendGCMTokenToActivity(string gcmToken)
        {
            Intent intent = new Intent(VoiceActivity.ACTION_SET_GCM_TOKEN);

            intent.putExtra(VoiceActivity.KEY_GCM_TOKEN, gcmToken);
            LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
        }
示例#4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Log.Error("Flowpilots", "Main Activity Started");

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            _listView = FindViewById <WearableListView>(Resource.Id.wearable_list);
            // Assign an adapter to the list
            var adapter = new Adapter(this, _elements);

            _listView.SetAdapter(adapter);

            // Set a click listener
            _listView.SetClickListener(this);

            #region Step 3
            // Register the local broadcast receiver, defined in step 3.
            var messageFilter   = new IntentFilter(Intent.ActionSend);
            var messageReceiver = new MessageReceiver();
            LocalBroadcastManager.GetInstance(this).RegisterReceiver(messageReceiver, messageFilter);

            #endregion
        }
示例#5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.AcShoppingLists);

            var startServiceIntent = new Intent(ShAppContext, typeof(SyncService));

            con = new SyncCom(this);
            ApplicationContext.BindService(startServiceIntent, con, Bind.AutoCreate);

            llShoppingLst = FindViewById <LinearLayout>(Resource.Id.listShopping);
            btnCreateList = FindViewById <Button>(Resource.Id.btnCreateList);

            btnCreateList.Click += AddNewList;

            LoadLists();
            GenerateUILists();

            IntentFilter    filter   = new IntentFilter(Intent.ActionSend);
            MessageReciever receiver = new MessageReciever(this);

            LocalBroadcastManager.GetInstance(this).RegisterReceiver(receiver, filter);

            PrepareDB();
        }//OnCreate
 private void UnregisterReceiver()
 {
     if (_receiver != null)
     {
         LocalBroadcastManager.GetInstance(this).UnregisterReceiver(_receiver);
     }
 }
示例#7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(R.Layouts.local_service_broadcaster);

            // This is where we print the data we get back.
            TextView callbackData = (TextView)FindViewById(R.Ids.callback);

            // Put in some initial text.
            callbackData.SetText("No broadcast received yet");

            // We use this to send broadcasts within our local process.
            mLocalBroadcastManager = LocalBroadcastManager.GetInstance(this);

            // We are going to watch for interesting local broadcasts.
            IntentFilter filter = new IntentFilter();

            filter.AddAction(ACTION_STARTED);
            filter.AddAction(ACTION_UPDATE);
            filter.AddAction(ACTION_STOPPED);
            mReceiver = new MyBroadcastReceiver(callbackData);

            mLocalBroadcastManager.RegisterReceiver(mReceiver, filter);

            // Watch for button clicks.
            Button button = (Button)FindViewById(R.Ids.start);

            button.Click += (o, e) => StartService(new Intent(this, typeof(LocalService)));
            button        = (Button)FindViewById(R.Ids.stop);
            button.Click += (o, e) => StopService(new Intent(this, typeof(LocalService)));
        }
示例#8
0
        public override void OnDestroy()
        {
            var notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Cancel(Constants.SERVICE_RUNNING_NOTIFICATION_ID);
            IsStarted = false;
            try
            {
                _cancellationTokenSource.Cancel();
            }
            catch { }

            LocalBroadcastManager.GetInstance(this).UnregisterReceiver(_defconStatusReceiver);
            try
            {
                udpClient.Close();
            }
            catch { }
            try
            {
                udpClient.Dispose();
            }
            catch { }
            try
            {
                _udpClientTask.Dispose();
            }
            catch { }

            base.OnDestroy();
        }
        private void _tlc_TimeLoggingStateChanged(object sender, StateChangedEventArgs e)
        {
            Intent intent = new Intent(eventName);

            // You can also include some extra data.
            System.Diagnostics.Debug.WriteLine("We have a change of state");

            if (e.NewState.Equals(TimeLoggingControllerStates.TimeLogCanceled))

            {
                intent.PutExtra("key", "Time logging has been cancelled by the server");

                // Communicate with the activity to update the UI
            }
            if (e.NewState.Equals(TimeLoggingControllerStates.TimeLogUpdated))
            {
                intent.PutExtra("key", "Time logging has been updated by the server");
            }

            if (e.NewState.Equals(TimeLoggingControllerStates.TimeLogCreated))
            {
                intent.PutExtra("key", "Time logging has been created by the server");
            }


            if (e.NewState.Equals(TimeLoggingControllerStates.TimeLogUpdateFailed))
            {
                intent.PutExtra("key", "Time logging Update has failed");
            }
            LocalBroadcastManager.GetInstance(this).SendBroadcast(intent);
        }
示例#10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.AcListItems);
            string id = Intent.GetStringExtra(Constants.KEY_ID_LIST);

            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            else
            {
                m_data = ListsManager.Instance.GetListByInternalId(id);
                if (m_data == null)
                {
                    return;
                }
            }//else

            llLst             = FindViewById <LinearLayout>(Resource.Id.lstItems);
            txtShoppingItem   = FindViewById <EditText>(Resource.Id.txtItemName);
            txtQuantity       = FindViewById <EditText>(Resource.Id.txtQuantity);
            btnAddItem        = FindViewById <Button>(Resource.Id.btnAddItem);
            btnAddItem.Click += AddNewItem;

            GenerateUIListItems();

            IntentFilter    filter   = new IntentFilter(Intent.ActionSend);
            MessageReciever receiver = new MessageReciever(this);

            LocalBroadcastManager.GetInstance(this).RegisterReceiver(receiver, filter);
        }//OnCreate
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            try
            {
                _taskId = intent.GetStringExtra("taskId");
                var pendingIntent = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(MainActivity)), 0);

                Notification.Builder builder = new Notification.Builder(this)
                                               .SetContentIntent(pendingIntent)
                                               .SetContentText("Timer is running")
                                               .SetContentTitle("Process Dashboard")
                                               .SetSmallIcon(Resource.Drawable.Icon);

                var ongoing = builder.Build();

                StartForeground((int)NotificationFlags.ForegroundService, ongoing);

                Intent intent2 = new Intent(eventName);

                //TODO: THERE SEEMS TO BE SOMETHING WEIRD HERE!!

                TimeLoggingController.TimeLoggingStateChanged += _tlc_TimeLoggingStateChanged;
                _tlc.StartTiming(_taskId);
                intent2.PutExtra("key", "Time logging has been started by the server");
                LocalBroadcastManager.GetInstance(this).SendBroadcast(intent2);
                System.Diagnostics.Debug.WriteLine("This is a foreground Service");
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
            return(StartCommandResult.RedeliverIntent);
        }
示例#12
0
        public void SendMessage(string messsage)
        {
            Intent intent = new Intent("com.InstaShit.Android.INFORMATION");

            intent.PutExtra("com.InstaShit.Android.INFORMATION_MESSAGE", messsage);
            LocalBroadcastManager.GetInstance(this).SendBroadcast(intent);
        }
        override public void OnResume()
        {
            base.OnResume();

            /*
             * var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
             * if (prefs.GetBoolean("settings_changes", false))
             * {
             *  adapter = new NotifAdapter(Activity, notifs);
             *  gridView.Adapter = adapter;
             *  gridView.ItemClick += GridOnItemClick;
             * }
             */

            if (micId != "All")
            {
                LocalBroadcastManager.GetInstance(_container.Context).RegisterReceiver(mRegistrationBroadcastReceiver, new IntentFilter("update_notifs"));

                if (!updatingNotifs)
                {
                    updatingNotifs = true;
                    RequestUpdateNotifs();
                }
            }
            else
            {
                LocalBroadcastManager.GetInstance(_container.Context).RegisterReceiver(mRegistrationBroadcastReceiver,
                                                                                       new IntentFilter("notif_All"));
            }
        }
 protected override void OnDestroy()
 {
     base.OnDestroy();
     LocalBroadcastManager.GetInstance(this).UnregisterReceiver(mySensorDataReceiver);
     LocalBroadcastManager.GetInstance(this).UnregisterReceiver(myStopSignalReceiver);
     switchServiceButton.Click -= SwitchService_Click;
 }
示例#15
0
        protected override void OnCreate(Bundle savedInstanceState) {
            base.OnCreate(savedInstanceState);

            SetContentView(R.Layout.local_service_broadcaster);

            // This is where we print the data we get back.
            TextView callbackData = (TextView)FindViewById(R.Id.callback);

            // Put in some initial text.
            callbackData.Text = ("No broadcast received yet");

            // We use this to send broadcasts within our local process.
            mLocalBroadcastManager = LocalBroadcastManager.GetInstance(this);

            // We are going to watch for interesting local broadcasts.
            IntentFilter filter = new IntentFilter();
            filter.AddAction(ACTION_STARTED);
            filter.AddAction(ACTION_UPDATE);
            filter.AddAction(ACTION_STOPPED);
            mReceiver = new MyBroadcastReceiver(callbackData);
            
            mLocalBroadcastManager.RegisterReceiver(mReceiver, filter);

            // Watch for button clicks.
            Button button = (Button)FindViewById(R.Id.start);
            button.Click += (o,e) => StartService(new Intent(this, typeof(LocalService)));
            button = (Button)FindViewById(R.Id.stop);
            button.Click += (o,e) => StopService(new Intent(this, typeof(LocalService)));
        }
示例#16
0
        private void InitServiceListener()
        {
            var intentFilter = new IntentFilter();

            intentFilter.AddAction(MusicPlayerService.PlayerStop);
            LocalBroadcastManager.GetInstance(this).RegisterReceiver(_broadcastReceiver, intentFilter);
        }
示例#17
0
        private void ForeGroundNotification(RemoteMessage message)
        {
            var data  = message.Data;
            var title = data["title"];
            var body  = data["body"];
            var extra = data["Action"];


            Intent intnt = new Intent("Notification");

            intnt.PutExtra("Action", extra);
            intnt.PutExtra("Title", title);
            intnt.PutExtra("Body", body);


            LocalBroadcastManager.GetInstance(this).SendBroadcast(intnt);

            ////var currentContext = LocalActivityManager;
            //LocalActivityManager.

            //AlertDialog.Builder dialog = new AlertDialog.Builder(currentContext);
            //AlertDialog alert = dialog.Create();
            //alert.SetTitle(title);
            //alert.SetIcon(Resource.Drawable.NotificationIcon);
            //alert.SetMessage(body);



            //currentContext.RunOnUiThread(() =>
            //            //Toast.MakeText(currentContext, "¡Lo sentimos! Las unidades no se encuentran disponibles.", ToastLength.Long).Show()
            //            alert.Show()
            //    );
        }
        protected override void OnPause()
        {
            base.OnPause();
            LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.GetInstance(this);

            localBroadcastManager.UnregisterReceiver(broadcastResponseReceiver);
        }
        public void StopReceivingCall()
        {
            Intent intent = new Intent(PlayerStop);

            LocalBroadcastManager.GetInstance(ApplicationContext).SendBroadcast(intent);
            Stop();
        }
 public override void OnResume()
 {
     //TODO:
     IsItemClicked = false;
     base.OnResume();
     LocalBroadcastManager.GetInstance(this.Activity).RegisterReceiver(attractionReceiver, UtilityService.GetLocationUpdatedIntentFilter());
 }
            public override void OnPause()
            {
                LocalBroadcastManager.GetInstance(Activity)
                .UnregisterReceiver(connStatusReceiver);

                base.OnPause();
            }
示例#22
0
 private void RegisterBroadcastReceiver()
 {
     mTokenBroadcastReceiver = new TokenBroadcastReceiver();
     LocalBroadcastManager.GetInstance(mActivity).RegisterReceiver(
         mTokenBroadcastReceiver,
         new IntentFilter(TokenIntentService.TOKEN_ACTION));
 }
示例#23
0
        protected override void OnStop()
        {
            base.OnStop();

            // Unregister download receiver
            LocalBroadcastManager.GetInstance(this).UnregisterReceiver(mDownloadReceiver);
        }
示例#24
0
        private void HandleError()
        {
            Intent intent = new Intent(PlayerError);

            LocalBroadcastManager.GetInstance(ApplicationContext).SendBroadcast(intent);
            Stop();
        }
 protected override void OnResume()
 {
     base.OnResume();
     LocalBroadcastManager.GetInstance(this).RegisterReceiver(mReceiver, new IntentFilter(ACTION_NOTIFY));
     mHistoryView.Text = "";
     StartResponderService(ACTION_GET_CONVERSATION);
 }
        protected override void OnHandleIntent(Intent intent)
        {
            var sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this);

            try {
                lock (TAG) {
                    var instanceID = InstanceID.GetInstance(this);
                    var token      = instanceID.GetToken(GetString(Resource.String.gcm_defaultSenderId),
                                                         GoogleCloudMessaging.InstanceIdScope, null);
                    Log.Info(TAG, "GCM Registration Token: " + token);

                    SendRegistrationToServer(token);

                    SubscribeTopics(token);

                    sharedPreferences.Edit().PutBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).Apply();
                }
            } catch (Exception e) {
                Log.Debug(TAG, "Failed to complete token refresh", e);
                // If an exception happens while fetching the new token or updating our registration data
                // on a third-party server, this ensures that we'll attempt the update at a later time.
                sharedPreferences.Edit().PutBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).Apply();
            }
            // Notify UI that registration has completed, so the progress indicator can be hidden.
            var registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);

            LocalBroadcastManager.GetInstance(this).SendBroadcast(registrationComplete);
        }
示例#27
0
        private void SendShowTitleBroadcast()
        {
            Intent broadcastIntent = new Intent(NotificationBroadcastAction);

            broadcastIntent.PutExtra(BroadcastMessageKey, BroadcastShowTitle);
            LocalBroadcastManager.GetInstance(this).SendBroadcast(broadcastIntent);
        }
示例#28
0
        public void OnConnected(Bundle connectionHint)
        {
            Task.Run(async() =>
            {
                await WearableClass.CapabilityApi.AddCapabilityListenerAsync(
                    mGoogleApiClient,
                    this,
                    WearableHelper.CAPABILITY_PHONE_APP);
                await WearableClass.DataApi.AddListenerAsync(mGoogleApiClient, this);
                await WearableClass.MessageApi.AddListenerAsync(mGoogleApiClient, this);

                mPhoneNodeWithApp = await CheckIfPhoneHasApp();

                if (mPhoneNodeWithApp == null)
                {
                    mConnectionStatus = WearConnectionStatus.AppNotInstalled;
                }
                else
                {
                    mConnectionStatus = WearConnectionStatus.Connected;
                }

                LocalBroadcastManager.GetInstance(this)
                .SendBroadcast(new Intent(ACTION_UPDATECONNECTIONSTATUS)
                               .PutExtra(EXTRA_CONNECTIONSTATUS, (int)mConnectionStatus));

                Loaded = true;
            });
        }
示例#29
0
        private void UpdateLocation(DataMap dataMap)
        {
            if (dataMap != null && !dataMap.IsEmpty)
            {
                var locationJSON = dataMap.GetString("locationData", String.Empty);
                if (!String.IsNullOrWhiteSpace(locationJSON))
                {
                    using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(new System.IO.StringReader(locationJSON)))
                    {
                        var locationData = WeatherData.LocationData.FromJson(jsonTextReader);

                        if (locationData != null)
                        {
                            if (!locationData.Equals(Settings.HomeData))
                            {
                                Settings.SaveHomeData(locationData);
                            }

                            // Send callback to receiver
                            LocalBroadcastManager.GetInstance(this).SendBroadcast(
                                new Intent(WearableHelper.LocationPath));
                        }
                    }
                }
            }
        }
示例#30
0
        private void UpdateSettings(DataMap dataMap)
        {
            if (dataMap != null && !dataMap.IsEmpty)
            {
                var API         = dataMap.GetString("API", String.Empty);
                var API_KEY     = dataMap.GetString("API_KEY", String.Empty);
                var KeyVerified = dataMap.GetBoolean("KeyVerified", false);
                if (!String.IsNullOrWhiteSpace(API))
                {
                    Settings.API = API;
                    if (WeatherData.WeatherManager.IsKeyRequired(API))
                    {
                        Settings.API_KEY     = API_KEY;
                        Settings.KeyVerified = KeyVerified;
                    }
                    else
                    {
                        Settings.API_KEY     = String.Empty;
                        Settings.KeyVerified = false;
                    }
                }

                Settings.FollowGPS = dataMap.GetBoolean("FollowGPS", false);

                // Send callback to receiver
                LocalBroadcastManager.GetInstance(this).SendBroadcast(
                    new Intent(WearableHelper.SettingsPath));
            }
        }
示例#31
0
        private async Task OpenAppOnPhone()
        {
            await Connect();

            if (mPhoneNodeWithApp == null)
            {
                Toast.MakeText(this, "Device is not connected or app is not installed on device...", ToastLength.Short).Show();

                int deviceType = PhoneDeviceType.GetPhoneDeviceType(this);
                switch (deviceType)
                {
                case PhoneDeviceType.DeviceTypeAndroid:
                    LocalBroadcastManager.GetInstance(this).SendBroadcast(
                        new Intent(ACTION_SHOWSTORELISTING));
                    break;

                case PhoneDeviceType.DeviceTypeIos:
                default:
                    Toast.MakeText(this, "Connected device is not supported", ToastLength.Short).Show();
                    break;
                }
            }
            else
            {
                // Send message to device to start activity
                var sendMessageResult = await WearableClass.MessageApi.SendMessageAsync(mGoogleApiClient, mPhoneNodeWithApp.Id,
                                                                                        WearableHelper.StartActivityPath, new byte[0]);

                LocalBroadcastManager.GetInstance(this)
                .SendBroadcast(new Intent(ACTION_OPENONPHONE)
                               .PutExtra(EXTRA_SUCCESS, sendMessageResult.Status.IsSuccess));
            }
        }
		public override void OnCreate ()
		{
			base.OnCreate ();
			if (Log.IsLoggable (TAG, LogPriority.Debug))
				Log.Debug (TAG, "Chat Service Started");
			mResponder = new ElizaResponder ();
			mBroadcastManager = LocalBroadcastManager.GetInstance (this);
			ProcessIncoming (null);
		}
示例#33
0
 public override void OnCreate() {
     base.OnCreate();
     mLocalBroadcastManager = LocalBroadcastManager.GetInstance(this);
 }
		public override void OnDestroy ()
		{
			if (Log.IsLoggable (TAG, LogPriority.Debug))
				Log.Debug (TAG, "Chat Service Stopped");
			NotificationManagerCompat.From (this).Cancel (0);
			mBroadcastManager = null;
			base.OnDestroy ();
		}