Esempio n. 1
0
        // ----------------------------------------------------------------------------------------------------------------
        // When the alert is dismissed by the player. The chronometer will continue the game clock.
        public void OnDismiss(IDialogInterface dialog)
        {
            chronometer.Base = SystemClock.ElapsedRealtime() + pausedAt;

            // Continue the chronometer.
            chronometer.Start();
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the state of the player.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="position"></param>
        public void UpdatePlaybackState(int state, int position = 0)
        {
            if (CurrentSession == null && (_binder?.IsBinderAlive).GetValueOrDefault(false) && !string.IsNullOrWhiteSpace(_packageName))
            {
                InitMediaSession(_packageName, _binder);
            }

            PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder()
                                                       .SetActions(PlaybackStateCompat.ActionPlay
                                                                   | PlaybackStateCompat.ActionPlayPause
                                                                   | PlaybackStateCompat.ActionPause
                                                                   | PlaybackStateCompat.ActionSkipToNext
                                                                   | PlaybackStateCompat.ActionSkipToPrevious
                                                                   | PlaybackStateCompat.ActionStop);

            stateBuilder.SetState(state, position, 0, SystemClock.ElapsedRealtime());
            CurrentSession?.SetPlaybackState(stateBuilder.Build());
            OnStatusChanged?.Invoke(CurrentSession, state);

            //Used for backwards compatibility
            if ((Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) &&
                (CurrentSession?.RemoteControlClient == null ||
                 (bool)!CurrentSession?.RemoteControlClient.Equals(typeof(RemoteControlClient))))
            {
                return;
            }

            RemoteControlClient remoteControlClient = (RemoteControlClient)CurrentSession?.RemoteControlClient;

            RemoteControlFlags flags = RemoteControlFlags.Play
                                       | RemoteControlFlags.Pause
                                       | RemoteControlFlags.PlayPause;

            remoteControlClient?.SetTransportControlFlags(flags);
        }
Esempio n. 3
0
        public void RegisterSchudle(Schudle s, DayOfWeek dayofwaek)
        {
            AlarmManager  alarm_mngr = (AlarmManager)context.GetSystemService(Context.AlarmService);
            Intent        intent     = new Intent("DroidVigia.DroidVigia.DroidVigia.SchudledAlarm");
            PendingIntent pintent    = PendingIntent.GetBroadcast(context, 0, intent, PendingIntentFlags.OneShot);
            var           pref_model = Global.GetAppPreferences(context);

            pref_model.Next_Schudle_Name = s.Label;
            var schudled_time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, s.Hour, s.Minute, 0);
            int diff_days     = 0;

            if (dayofwaek > DateTime.Now.DayOfWeek)
            {
                diff_days = dayofwaek - DateTime.Now.DayOfWeek;
            }
            if (dayofwaek < DateTime.Now.DayOfWeek)
            {
                diff_days = (DayOfWeek.Saturday - DateTime.Now.DayOfWeek) + ((int)dayofwaek + 1);
            }
            schudled_time = schudled_time.AddDays(diff_days);
            long millis = (long)(schudled_time - DateTime.Now).TotalMilliseconds;

            //Calendar future= Calendar.GetInstance(Java.Util.TimeZone.Default);
            //future.Add(Java.Util.CalendarField.Millisecond, (int)millis);
            alarm_mngr.Set(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + millis, pintent);
        }
Esempio n. 4
0
        public void Remind(DateTime dateTime, string title, string message)
        {
            // create alarm intent
            Intent alarmIntent = new Intent(Application.Context, typeof(AlarmReceiver));

            alarmIntent.PutExtra("message", message);
            alarmIntent.PutExtra("title", title);

            // specify the broadcast receiver
            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
            AlarmManager  alarmManager  = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService);

            // set the time when app is woken up
            // todo: this is where time is adjusted
            //alarmManager.SetInexactRepeating(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + 5* 1000, 1000, pendingIntent);

            alarmManager.Set(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + 1 * 1000, pendingIntent);



            ////Intent alarmIntent = new Intent(this, typeof(AlarmReceiver));

            ////PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
            ////AlarmManager alarmManager = (AlarmManager)GetSystemService(Context.AlarmService);
            //var tomorrowMorningTime = new DateTime(DateTime.Now.AddDays(1).Year, DateTime.Now.AddDays(1).Month, DateTime.Now.AddDays(1).Day, 0, 0, 1);
            //var timeDifference = tomorrowMorningTime – DateTime.Now;
            //var millisecondsInOneDay = 86400000;
            //alarmManager.SetInexactRepeating(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + (long)timeDifference.TotalMilliseconds, (long)millisecondsInOneDay, pendingIntent);
        }
        void IReminderNotification.AddNotification(DateTimeOffset maintenanceReminderStartDateTime, int dailyInterval, int maintenanceReminderRepetition,
                                                   string title, string body, bool isUnlimited)
        {
            pendingIntents = new List <PendingIntent>();

            // time when the first notification should appear from now on (if time is in the past, the notification will be fired immediately).
            TimeSpan reminderTime = maintenanceReminderStartDateTime - DateTimeOffset.Now;

            int  dailyMiliseconds      = 86400000;
            long intervalInMiliseconds = dailyMiliseconds * dailyInterval;

            long currentReminderTime      = SystemClock.ElapsedRealtime() + (long)reminderTime.TotalMilliseconds;
            int  countReminderRepetitions = 0;

            //If a limit is set, add the planned amount of reminders to the scheduler
            if (!isUnlimited)
            {
                while (countReminderRepetitions <= maintenanceReminderRepetition)
                {
                    PendingIntent intent = createPendingIntent(title, body, countReminderRepetitions);
                    alarmManager.Set(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + (long)reminderTime.TotalMilliseconds + (countReminderRepetitions * intervalInMiliseconds), intent);
                    pendingIntents.Add(intent);
                    countReminderRepetitions++;
                }
            }

            //if no limit is set, add a repeating alarm
            else
            {
                PendingIntent intent = createPendingIntent(title, body, countReminderRepetitions);
                alarmManager.SetRepeating(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + (long)reminderTime.TotalMilliseconds, (dailyMiliseconds * dailyInterval), intent);
                pendingIntents.Add(intent);
            }
        }
        private void btnSet_Click(object sender, EventArgs eventArgs)
        {
            var intent = new Intent(this, typeof(OneShotAlarm));
            var source = PendingIntent.GetBroadcast(this, 0, intent, 0);

            currenttime = DateTime.Now;
            int actualTime = currenttime.Hour * 60 + currenttime.Minute;
            int inputTime  = (Convert.ToInt32(timePicker.CurrentHour)) * 60 + (Convert.ToInt32(timePicker.CurrentMinute));

            if (inputTime < actualTime)
            {
                currenttime = currenttime.AddDays(1);
                currentHr   = Convert.ToInt32(timePicker.CurrentHour);
                currentMin  = Convert.ToInt32(timePicker.CurrentMinute);
            }
            else
            {
                currentHr  = Convert.ToInt32(timePicker.CurrentHour) - currenttime.Hour;
                currentMin = Convert.ToInt32(timePicker.CurrentMinute) - currenttime.Minute;
            }

            interval = (((currentHr * 60) * 60) + ((currentMin) * 60)) * 1000;

            // Schedule the alarm for 30 seconds from now!
            var am = (AlarmManager)GetSystemService(AlarmService);

            am.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + interval, source);
            StartActivity(typeof(SecondActivity));
        }
Esempio n. 7
0
        private void BtnTimerPause_clicked(object sender, EventArgs e)
        {
            Chronometer chrono = FindViewById <Chronometer>(Resource.Id.chronoHelper);

            timeWhenStopped = chrono.Base - SystemClock.ElapsedRealtime();
            chrono.Stop();
        }
Esempio n. 8
0
        public override void OnCreate()
        {
            base.OnCreate();

            // Register ScreenOn, ScreenOff intents
            RegisterReceiver(IntentBroadcastReceiver.Instance, new IntentFilter(Intent.ActionScreenOn));
            RegisterReceiver(IntentBroadcastReceiver.Instance, new IntentFilter(Intent.ActionScreenOff));

            PowerManager powerManager = GetSystemService(PowerService) as PowerManager;

            if (!powerManager.IsInteractive)
            {
                StopSelf();
                return;
            }

            // Create widget update intent
            Intent intent = new Intent();

            intent.SetAction(AppWidgetManager.ActionAppwidgetUpdate);
            PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, 0, intent, 0);

            // Setup an alarm
            AlarmManager alarmManager = GetSystemService(AlarmService) as AlarmManager;

            alarmManager.SetInexactRepeating(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime(), TramUrWayApplication.WidgetUpdateDelay * 1000, pendingIntent);
        }
        private void UpdatePlaybackState(String error)
        {
            var position = PlaybackState.PlaybackPositionUnknown;

            if (_musicPlayer != null)
            {
                position = _musicPlayer.CurrentStreamPosition;
            }

            var stateBuilder = new PlaybackState.Builder()
                               .SetActions(GetAvailableActions());

            SetCustomAction(stateBuilder);

            if (error != null)
            {
                stateBuilder.SetErrorMessage(error);
                stateBuilder.SetState(PlaybackStateCode.Error, position, 1.0f, SystemClock.ElapsedRealtime());
            }
            else
            {
                stateBuilder.SetState(_musicPlayer.MusicPlayerState, position, 1.0f, SystemClock.ElapsedRealtime());
            }

            if (this.isIndexPlayable(_currentIndexQueue, _playingQueue))
            {
                var item = _playingQueue[_currentIndexQueue];
                stateBuilder.SetActiveQueueItemId(item.QueueId);
            }

            _session.SetPlaybackState(stateBuilder.Build());
        }
Esempio n. 10
0
        protected override void OnCreate(Bundle bundle)
        {
            ToolbarResource   = Resource.Layout.Toolbar;
            TabLayoutResource = Resource.Layout.Tabbar;

            base.OnCreate(bundle);
            Xamarin.Essentials.Platform.Init(this, bundle);
            CrossCurrentActivity.Current.Init(this, bundle);
            Forms.Init(this, bundle);

            LoadApplication(new App());

            //var intent = new Intent(this, typeof(PeriodicService));
            //StartService(intent);


            var alarmIntent = new Intent(this, typeof(BackgroundReceiver));

            var pending = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);

            var alarmManager = GetSystemService(AlarmService).JavaCast <AlarmManager>();

            alarmManager.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + 5 * 1000, pending);
            //    alarmManager.SetRepeating(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + 5 * 1000, 5*1000, pending);

            // IsPlayServicesAvailable();
        }
Esempio n. 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AppCenter.Start(Secrets.ANDROID_APP_CENTER_SECRET, typeof(Analytics), typeof(Crashes));

            adapter = new TabsAdapter(this, SupportFragmentManager);
            pager   = FindViewById <ViewPager>(Resource.Id.viewpager);
            var tabs = FindViewById <TabLayout>(Resource.Id.tabs);

            pager.Adapter = adapter;
            tabs.SetupWithViewPager(pager);
            pager.OffscreenPageLimit = 3;

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);

            var alarmIntent   = new Intent(this, typeof(AlarmReceiver));
            var pendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, 0);

            var alarmManager = AlarmManager.FromContext(this);

            alarmManager.SetInexactRepeating(AlarmType.ElapsedRealtimeWakeup,
                                             SystemClock.ElapsedRealtime() + AlarmManager.IntervalHalfHour,
                                             AlarmManager.IntervalHalfHour,
                                             pendingIntent);
        }
Esempio n. 12
0
        //    This event receives estimation results from other devices in the server room. In order
        //    to receive anything, make sure you call startUDP to connect to a room. Again, it provides
        //    access to a MotionDna object, which can be unpacked the same way as above.
        //
        //
        //    If you aren't receiving anything, then the room may be full, or there may be an error in
        //    your connection. See the reportError event below for more information.
        public void ReceiveNetworkData(MotionDna motionDna)
        {
            networkUsers[motionDna.ID] = motionDna;
            double timeSinceBootSeconds = SystemClock.ElapsedRealtime() / 1000.0;

            networkUsersTimestamps[motionDna.ID] = timeSinceBootSeconds;
            StringBuilder activeNetworkUsersStringBuilder = new StringBuilder();
            List <string> toRemove = new List <string>();

            activeNetworkUsersStringBuilder.Append("Network Shared Devices:\n");
            foreach (MotionDna user in networkUsers.Values)
            {
                if (timeSinceBootSeconds - networkUsersTimestamps[user.ID] > 2.0)
                {
                    toRemove.Add(user.ID);
                }
                else
                {
                    activeNetworkUsersStringBuilder.Append(user.DeviceName);
                    MotionDna.XYZ location = user.GetLocation().LocalLocation;
                    activeNetworkUsersStringBuilder.Append(string.Format(" ({0:2F}, {1:2F}, {2:2F})", location.X, location.Y, location.Z));
                    activeNetworkUsersStringBuilder.Append("\n");
                }
            }
            foreach (string key in toRemove)
            {
                networkUsers.Remove(key);
                networkUsersTimestamps.Remove(key);
            }

            networkTextView.Text = activeNetworkUsersStringBuilder.ToString();
        }
Esempio n. 13
0
        private void StartAlarm(bool isNotification, bool isRepeating)
        {
            AlarmManager  manager = (AlarmManager)GetSystemService(Context.AlarmService);
            Intent        myIntent;
            PendingIntent pendingIntent;

            if (!isNotification)
            {
                myIntent      = new Intent(this, typeof(AlarmToastReceiver));
                pendingIntent = PendingIntent.GetBroadcast(this, 0, myIntent, 0);
            }
            else
            {
                myIntent      = new Intent(this, typeof(AlarmNotificationReceiver));
                pendingIntent = PendingIntent.GetBroadcast(this, 0, myIntent, 0);
            }

            if (!isRepeating)
            {
                manager.Set(AlarmType.RtcWakeup, SystemClock.ElapsedRealtime() + 3000, pendingIntent);
            }
            else
            {
                manager.SetRepeating(AlarmType.RtcWakeup, SystemClock.ElapsedRealtime() + 3000, 60 * 1000, pendingIntent);
            }
        }
Esempio n. 14
0
            // Draw a 3 dimensional line on to the screen
            void DrawLine(Canvas c, int x1, int y1, int z1, int x2, int y2, int z2)
            {
                long  now  = SystemClock.ElapsedRealtime();
                float xrot = ((float)(now - start_time)) / 1000;
                float yrot = (0.5f - offset) * 2.0f;
                float zrot = 0;

                // 3D transformations

                // rotation around X-axis
                float newy1 = (float)(Math.Sin(xrot) * z1 + Math.Cos(xrot) * y1);
                float newy2 = (float)(Math.Sin(xrot) * z2 + Math.Cos(xrot) * y2);
                float newz1 = (float)(Math.Cos(xrot) * z1 - Math.Sin(xrot) * y1);
                float newz2 = (float)(Math.Cos(xrot) * z2 - Math.Sin(xrot) * y2);

                // rotation around Y-axis
                float newx1 = (float)(Math.Sin(yrot) * newz1 + Math.Cos(yrot) * x1);
                float newx2 = (float)(Math.Sin(yrot) * newz2 + Math.Cos(yrot) * x2);

                newz1 = (float)(Math.Cos(yrot) * newz1 - Math.Sin(yrot) * x1);
                newz2 = (float)(Math.Cos(yrot) * newz2 - Math.Sin(yrot) * x2);

                // 3D-to-2D projection
                float startX = newx1 / (4 - newz1 / 400);
                float startY = newy1 / (4 - newz1 / 400);
                float stopX  = newx2 / (4 - newz2 / 400);
                float stopY  = newy2 / (4 - newz2 / 400);

                c.DrawLine(startX, startY, stopX, stopY, paint);
            }
        private void OnButtonDelayAlarmClicked(object sender, System.EventArgs e)
        {
            Toast toast = Toast.MakeText(c, "+10 seconds", ToastLength.Short);

            manager.SetExact(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + 10000, pi);
            toast.Show();
        }
Esempio n. 16
0
        private void SendOnClick(object sender, EventArgs eventArgs)
        {
            SmsManager _smsManager;

            _smsManager = SmsManager.Default;

            EditText boy   = FindViewById <EditText>(Resource.Id.First);
            EditText girl  = FindViewById <EditText>(Resource.Id.FirstG);
            EditText boyM  = FindViewById <EditText>(Resource.Id.Middle);
            EditText girlM = FindViewById <EditText>(Resource.Id.MiddleG);

            if (boy.Text == "")
            {
                GenerateNames();
            }
            //_smsManager.SendTextMessage("4197969464", null, "message", null, null);
            _smsManager.SendTextMessage("9375704370", null, "Boy Name: " + boy.Text + " " + boyM.Text + "\n" + "Girl Name: " + girl.Text + " " + girlM.Text, null, null);
            if (!reminderSet)
            {
                Intent        alarmIntent = new Intent(this, typeof(AlarmReceiver));
                PendingIntent pending     = PendingIntent.GetBroadcast(Application.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
                am = (AlarmManager)this.GetSystemService(AlarmService);

                DateTime currentTime = DateTime.Now;
                var      triggerTime = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, 6, 0, 0);
                var      triggerSpan = TimeSpan.FromDays(1).Subtract(currentTime.Subtract(triggerTime));
                am.SetExact(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + (long)triggerSpan.TotalMilliseconds, pending);
                double tmp = triggerSpan.TotalMilliseconds;
                LongToast("You will be notified in : " + ((int)tmp / 3600000).ToString() + "Hours " + (((int)tmp % 3600000) / 60000).ToString() + "Minutes");
                reminderSet = true;
            }
        }
        private void SetAlarm()
        {
            Toast toast = Toast.MakeText(c, "15 seconds", ToastLength.Short);

            manager.SetExact(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + 15000, pi);
            toast.Show();
        }
Esempio n. 18
0
        private async void onLoginButtonClicked(object sender, EventArgs args)
        {
            if (SystemClock.ElapsedRealtime() - LastButtonClickTime < 1000)
            {
                return;
            }
            LastButtonClickTime = SystemClock.ElapsedRealtime();
            RestClient <Task> _restClient = new RestClient <Task>();

            //get token with username and password: done in the RestClient class
            var token = await _restClient.checkLogin(EntryUsername.Text, EntryPassword.Text);

            //ARRANJAR PARA QUANDO O SERVER ESTIVER EM BAIXO TAMBÉM
            if (token != null)
            {
                //login with token and id_user
                User u = new User();
                await u.setInfo(token, EntryUsername.Text);

                if (u.permissoes != 1)
                {
                    await Navigation.PushAsync(new Admin(u, token));
                }
                else if (u.permissoes == 1)
                {
                    await Navigation.PushAsync(new Perfil(u, token));
                }
            }
            else
            {
                await DisplayAlert("Error", "Invalid Credentials", "Try Again");
            }
        }
        private void btnRandom_Click(object sender, EventArgs eventArgs)
        {
            var intent = new Intent(this, typeof(OneShotAlarm));
            var source = PendingIntent.GetBroadcast(this, 0, intent, 0);

            var random = new System.Random();
            var start  = TimeSpan.FromHours(17);
            var end    = TimeSpan.FromHours(18);

            maxMinutes = (int)((end - start).TotalMinutes);
            minutes    = random.Next(maxMinutes);

            TimeSpan t = start.Add(TimeSpan.FromMinutes(minutes));

            randomHr    = t.Hours;
            randomMin   = t.Minutes;
            currenttime = DateTime.Now;
            currentHr   = randomHr - currenttime.Hour;
            currentMin  = randomMin - currenttime.Minute;

            interval = (((currentHr * 60) * 60) + (currentMin * 60)) * 1000;

            var am = (AlarmManager)GetSystemService(AlarmService);

            am.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + interval, source);
            StartActivity(typeof(SecondActivity));
        }
Esempio n. 20
0
    private void UpdatePlaybackState(PlaybackStateCode state)
    {
        if (mediaSession == null || mediaPlayer == null)
        {
            return;
        }

        try
        {
            PlaybackState.Builder stateBuilder = new PlaybackState.Builder()
                                                 .SetActions(
                PlaybackState.ActionPause |
                PlaybackState.ActionPlay |
                PlaybackState.ActionPlayPause |
                PlaybackState.ActionSkipToNext |
                PlaybackState.ActionSkipToPrevious |
                PlaybackState.ActionStop
                )
                                                 .SetState(state, Position, 1.0f, SystemClock.ElapsedRealtime());

            mediaSession.SetPlaybackState(stateBuilder.Build());

            OnStatusChanged(EventArgs.Empty);

            if (state == PlaybackStateCode.Playing || state == PlaybackStateCode.Paused)
            {
                StartNotification();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
Esempio n. 21
0
        private async void onDeleteUserClicked(object sender, EventArgs args)
        {
            if (SystemClock.ElapsedRealtime() - LastButtonClickTime < 1000)
            {
                return;
            }
            LastButtonClickTime = SystemClock.ElapsedRealtime();
            if (String.IsNullOrWhiteSpace(USERNAME.Text))
            {
                await DisplayAlert("", "Invalid Parameter", "Try Again");

                return;
            }

            bool action = await DisplayAlert("", "Are you sure you want to delete the user: "******"?", "Yes", "No");

            if (action)
            {
                bool res = await this.deleteUser(USERNAME.Text, token);

                if (res)
                {
                    await DisplayAlert("", "User deleted with success", "Ok");
                }

                else
                {
                    await DisplayAlert("", "User does not exist", "Try Again");
                }
            }
        }
        public void OnActionDown(RecordButton recordBtn, MotionEvent motionEvent)
        {
            try
            {
                RecordListener?.OnStartRecord();

                AnimationHelper.SetStartRecorded(true);
                AnimationHelper.ResetBasketAnimation();
                AnimationHelper.ResetSmallMic();

                recordBtn.StartScale();
                SlideToCancelLayout.StartShimmerAnimation();

                InitialX = recordBtn.GetX();

                BasketInitialY = BasketImg.GetY() + 90;

                PlaySound(RecordStart);

                ShowViews();

                AnimationHelper.AnimateSmallMicAlpha();
                CounterTime.Base = SystemClock.ElapsedRealtime();
                StartTime        = Methods.Time.CurrentTimeMillis();
                CounterTime.Start();
                IsSwiped = false;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Esempio n. 23
0
        private void IniciarAlarme(bool isNotificacao, bool isRepetirAlarme)
        {
            AlarmManager  manager = (AlarmManager)GetSystemService(Context.AlarmService);
            Intent        minhaIntent;
            PendingIntent pendingIntent;

            if (!isNotificacao)
            {
                minhaIntent   = new Intent(this, typeof(AlarmeMensagemReceiver));
                pendingIntent = PendingIntent.GetBroadcast(this, 0, minhaIntent, 0);
            }
            else
            {
                minhaIntent   = new Intent(this, typeof(AlarmeNotificacaoReceiver));
                pendingIntent = PendingIntent.GetBroadcast(this, 0, minhaIntent, 0);
            }
            if (!isRepetirAlarme)
            {
                manager.Set(AlarmType.RtcWakeup, SystemClock.ElapsedRealtime() + 3000, pendingIntent);
            }
            else
            {
                manager.SetRepeating(AlarmType.RtcWakeup, SystemClock.ElapsedRealtime() + 3000, 60 * 1000, pendingIntent);
            }
        }
Esempio n. 24
0
        private async void onChangePasswordClicked(object sender, EventArgs args)
        {
            if (SystemClock.ElapsedRealtime() - LastButtonClickTime < 1000)
            {
                return;
            }
            LastButtonClickTime = SystemClock.ElapsedRealtime();
            bool match = matchPass(NEWPASS1.Text, NEWPASS2.Text);

            if (match == true)
            {
                if (String.IsNullOrWhiteSpace(NEWPASS1.Text))
                {
                    await DisplayAlert("", "Invalid Credentials", "Try Again");

                    return;
                }
                bool res = await this.putPassword(OLDPASS.Text, NEWPASS1.Text, token);

                if (res)
                {
                    await DisplayAlert("", "Password changed with success", "Ok");
                }
                else
                {
                    await DisplayAlert("", "Invalid Credentials", "Try Again");
                }
            }
            else
            {
                await DisplayAlert("", "Inserted passwords don't match", "Try Again");
            }
        }
Esempio n. 25
0
        void UpdateSession()
        {
            var stateBuilder = new PlaybackStateCompat.Builder().SetActions(AvailableActions);



            Console.WriteLine("************");
            Console.WriteLine("***************");
            Console.WriteLine($"Media player: Playback State: {StateIsPlaying}/{IsPlaying} - position {Position}");
            Console.WriteLine("***************");
            Console.WriteLine("******");

            var favIcon            = Parent.CurrentSong?.Rating > 1 ? Resource.Drawable.ic_star_on : Resource.Drawable.ic_star_off;
            var customActionExtras = new Bundle();

            //TODO: run through wearables
            stateBuilder.AddCustomAction(
                new PlaybackStateCompat.CustomAction.Builder("THUMBSUP", "FAVORITE", favIcon).SetExtras(customActionExtras).Build());
            stateBuilder.SetState(State, Position, 1f, SystemClock.ElapsedRealtime());

            MusicService.Shared.Session.SetPlaybackState(stateBuilder.Build());

            if (State == PlaybackStateCompat.StatePlaying || State == PlaybackStateCompat.StatePaused)
            {
                MusicService.Shared.MediaNotificationManager.StartNotification();
            }
        }
 private void delete()
 {
     isRecording = false;
     rangeTime   = 0;
     ivStart.SetImageResource(Resource.Drawable.nim_video_capture_start_btn);
     ivBack.Visibility   = ViewStates.Gone;
     ivDelete.Visibility = ViewStates.Gone;
     try
     {
         if (camera != null)
         {
             camera.StartPreview();
         }
         chronometer.Base = SystemClock.ElapsedRealtime();
         System.IO.File.Delete(savePath);
     }
     catch (Exception ex)
     {
         Console.WriteLine("===delete error:" + ex);
     }
     finally
     {
         resetSavePath();
     }
 }
Esempio n. 27
0
            public void OnItemClick(AdapterView parent, View view, int position, long id)
            {
                if (SystemClock.ElapsedRealtime() - mLastClickTime < 1000)
                {
                    return;
                }
                mLastClickTime = SystemClock.ElapsedRealtime();

                if (notification[position].Type == "FR")
                {
                    Intent intent = new Intent(activity, typeof(FriendRequestActivity));
                    activity.StartActivity(intent);
                }
                else
                if (notification[position].Type == "ER")
                {
                    var fragment = new EventRequestFragment();
                    Android.Support.V4.App.FragmentManager FragmentManager = activity.SupportFragmentManager;
                    MainActivity.myBundle.PutLong("EventID", notification[position].EventID);
                    FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment, "eventRequest").AddToBackStack("eventRequest").Commit();
                }
                else
                if (notification[position].Type == "FA")
                {
                    var    item         = notification[position];
                    Intent mainActivity = new Intent(activity, typeof(MainActivity));
                    mainActivity.PutExtra("FromPeople", item.SenderID);
                    activity.StartActivity(mainActivity);
                }
                else
                if (notification[position].Type == "WE")
                {
                    new getWeClipInfo(activity, notification[position].WeClipID).Execute();
                }
            }
Esempio n. 28
0
 public EventLogger(MappingTrackSelector trackSelector)
 {
     this.trackSelector = trackSelector;
     window             = new Timeline.Window();
     period             = new Timeline.Period();
     startTimeMs        = SystemClock.ElapsedRealtime();
 }
Esempio n. 29
0
        public void AddNotification(int identifier, string title, string message, DateTime scheduledDateTime)
        {
            if (Notifications.ContainsKey(identifier))
            {
                RemoveNotification(identifier);
            }

            Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReceiver));

            alarmIntent.PutExtra("message", message);
            alarmIntent.PutExtra("title", title);

            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent,
                                                                     PendingIntentFlags.UpdateCurrent);
            AlarmManager alarmManager = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);

            Calendar calendarScheduled = Calendar.GetInstance(Locale.German);

            calendarScheduled.Set(scheduledDateTime.Year, scheduledDateTime.Month,
                                  scheduledDateTime.Day, scheduledDateTime.Hour, scheduledDateTime.Minute,
                                  scheduledDateTime.Second);

            Calendar calendarNow = Calendar.GetInstance(Locale.German);
            var      now         = DateTime.Now;

            calendarNow.Set(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            long alertInMillisFromNow = calendarScheduled.TimeInMillis - calendarNow.TimeInMillis;

            if (alertInMillisFromNow > 0)
            {
                alarmManager.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + alertInMillisFromNow, pendingIntent);
                Notifications.Add(identifier, pendingIntent);
            }
        }
Esempio n. 30
0
        internal static long ToElapsedRealtime(this DateTime value)
        {
            var utcValue = value.ToUniversalTime();
            var diff     = JavaSystem.CurrentTimeMillis() - SystemClock.ElapsedRealtime();

            return(Convert.ToInt64((utcValue - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).Add(TimeSpan.FromMilliseconds(-diff)).TotalMilliseconds) + 1000);
        }