private async Task cancelPendingIntentsForMedicationSchedule()//List<MedicationSchedule> _medications
        {
            Log.Error(Log_Tag, "start canceling pi");
            NetworkingData            networking = new NetworkingData();
            List <MedicationSchedule> list       = new List <MedicationSchedule>(await networking.ReadListFromDbFutureDataTask());


            foreach (MedicationSchedule item in list)
            {
                Log.Error(Log_Tag, "canceling pi .. " + item.IdNotification);
                var           am     = (AlarmManager)Application.Context.GetSystemService(AlarmService);
                var           intent = new Intent(BaseContext, typeof(AlarmBroadcastReceiverServer));
                PendingIntent pi     = PendingIntent.GetBroadcast(Application.Context, item.IdNotification, intent, 0);
                //pi.Cancel();

                if (pi == null)
                {
                    Log.Error(Log_Tag, "pi is null");
                }
                else
                {
                    Log.Error(Log_Tag, "pi is not null");
                }

                am.Cancel(pi);
                pi.Cancel();
                // networking.removeMedSer(item.Uuid);
            }
        }
Ejemplo n.º 2
0
        private async Task cancelPendingIntentsForMedicationSchedule()
        {
            Log.Error("MainActivity", "start canceling pending intents");
            try {
                NetworkingData            networking = new NetworkingData();
                List <MedicationSchedule> list       = new List <MedicationSchedule>(await networking.ReadListFromDbFutureDataTask());
                var am = (AlarmManager)Application.Context.GetSystemService(AlarmService);

                foreach (MedicationSchedule item in list)
                {
                    Log.Error("MainActivity", "canceling pi .. " + item.IdNotification);
                    var           intent = new Intent(Application.Context, typeof(AlarmBroadcastReceiverServer));
                    PendingIntent pi     = PendingIntent.GetBroadcast(Application.Context, item.IdNotification, intent, 0);

                    if (pi == null)
                    {
                        Log.Error("MainActivity", "pi is null");
                    }
                    else
                    {
                        Log.Error("MainActivity", "pi is not null");
                    }

                    //pi.Cancel();
                    am.Cancel(pi);
                    pi.Cancel();
                    //networking.removeMedSer(item.Uuid);
                }

                Log.Error("MainActivity", "finish canceling pending intents");
            } catch (Exception e) {
                Log.Error("MainActivity", "canceling pi ERROR" + e.Message);
            }
        }