Ejemplo n.º 1
0
        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"));
            }
        }
Ejemplo n.º 2
0
        private void HandleError()
        {
            Intent intent = new Intent(PlayerError);

            LocalBroadcastManager.GetInstance(ApplicationContext).SendBroadcast(intent);
            Stop();
        }
            public override void OnPause()
            {
                LocalBroadcastManager.GetInstance(Activity)
                .UnregisterReceiver(connStatusReceiver);

                base.OnPause();
            }
Ejemplo n.º 4
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));
                        }
                    }
                }
            }
        }
        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);
        }
Ejemplo n.º 6
0
 private void RegisterBroadcastReceiver()
 {
     mTokenBroadcastReceiver = new TokenBroadcastReceiver();
     LocalBroadcastManager.GetInstance(mActivity).RegisterReceiver(
         mTokenBroadcastReceiver,
         new IntentFilter(TokenIntentService.TOKEN_ACTION));
 }
Ejemplo n.º 7
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));
            }
        }
 private void UnregisterReceiver()
 {
     if (_receiver != null)
     {
         LocalBroadcastManager.GetInstance(this).UnregisterReceiver(_receiver);
     }
 }
        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);
        }
        public override void OnStop()
        {
            base.OnStop();

            UnregisterReceiver(gcmReceiver);
            LocalBroadcastManager.GetInstance(this).UnregisterReceiver(receiver);
        }
Ejemplo n.º 11
0
        public override void OnPause()
        {
            base.OnPause();
            LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.GetInstance(Context);

            localBroadcastManager.UnregisterReceiver(channelIdUpdateReceiver);
        }
Ejemplo n.º 12
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
        }
Ejemplo n.º 13
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
        protected override void OnPause()
        {
            base.OnPause();
            LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.GetInstance(this);

            localBroadcastManager.UnregisterReceiver(broadcastResponseReceiver);
        }
 protected override void OnDestroy()
 {
     base.OnDestroy();
     LocalBroadcastManager.GetInstance(this).UnregisterReceiver(mySensorDataReceiver);
     LocalBroadcastManager.GetInstance(this).UnregisterReceiver(myStopSignalReceiver);
     switchServiceButton.Click -= SwitchService_Click;
 }
        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);
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
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
Ejemplo n.º 19
0
 protected override void OnResume()
 {
     base.OnResume();
     LocalBroadcastManager.GetInstance(this).RegisterReceiver(mReceiver, new IntentFilter(ACTION_NOTIFY));
     mHistoryView.Text = "";
     StartResponderService(ACTION_GET_CONVERSATION);
 }
 public override void OnResume()
 {
     //TODO:
     IsItemClicked = false;
     base.OnResume();
     LocalBroadcastManager.GetInstance(this.Activity).RegisterReceiver(attractionReceiver, UtilityService.GetLocationUpdatedIntentFilter());
 }
Ejemplo n.º 21
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));
            }
        }
Ejemplo n.º 22
0
        public void StopReceivingCall()
        {
            Intent intent = new Intent(PlayerStop);

            LocalBroadcastManager.GetInstance(ApplicationContext).SendBroadcast(intent);
            Stop();
        }
Ejemplo n.º 23
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;
            });
        }
Ejemplo n.º 24
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)));
        }
Ejemplo n.º 25
0
        private void SendShowTitleBroadcast()
        {
            Intent broadcastIntent = new Intent(NotificationBroadcastAction);

            broadcastIntent.PutExtra(BroadcastMessageKey, BroadcastShowTitle);
            LocalBroadcastManager.GetInstance(this).SendBroadcast(broadcastIntent);
        }
Ejemplo n.º 26
0
        private void InitServiceListener()
        {
            var intentFilter = new IntentFilter();

            intentFilter.AddAction(MusicPlayerService.PlayerStop);
            LocalBroadcastManager.GetInstance(this).RegisterReceiver(_broadcastReceiver, intentFilter);
        }
Ejemplo n.º 27
0
        protected override void OnStop()
        {
            base.OnStop();

            // Unregister download receiver
            LocalBroadcastManager.GetInstance(this).UnregisterReceiver(mDownloadReceiver);
        }
Ejemplo n.º 28
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()
            //    );
        }
Ejemplo n.º 29
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();
        }
Ejemplo n.º 30
0
        void Probar_OnClick(object sender, EventArgs e)
        {
            prefmodel.SetNumberString(tb_numbers.Text);
            prefmodel.DoSilence = this.chkb_dosilence.Checked;
            prefmodel.DoMMS     = this.chkb_MMS.Checked;
            prefmodel.DoMessage = this.chkb_Message.Checked;
            prefmodel.DoCall    = this.chkb_LLamar.Checked;
            if (!prefmodel.IsValidNumbersString())
            {
                Toast.MakeText(this, "Secuencia de Numeros Incorrecta", ToastLength.Long);
            }
            else
            {
                Toast.MakeText(this, "Preferencias Guardadas", ToastLength.Long);

                tone_detected_reciver = new ToneDetectedReciver();
                LocalBroadcastManager bc_mngr = LocalBroadcastManager.GetInstance(this);
                bc_mngr.RegisterReceiver(tone_detected_reciver, new IntentFilter("DroidVigia.DroidVigia.DroidVigia.ToneDetected"));
                var intent = new Intent("DroidVigia.DroidVigia.DroidVigia.ToneDetected");
                intent.PutExtra("message", "Prueba de Envio");
                bc_mngr.SendBroadcastSync(intent);
                bc_mngr.UnregisterReceiver(tone_detected_reciver);
                tone_detected_reciver = null;
            }
        }