Einzelnen Beitrag anzeigen

Rudirabbit

Registriert seit: 27. Sep 2006
111 Beiträge
 
#1

Delphi X5 Android TNotificationCenter

  Alt 12. Okt 2013, 18:10
Hallo,
Ich versuche schon länger eine Wecker App zu programmieren.
Wann geweckt werden soll, das ist alles schon fertig.

So eine Weckerapp funktioniert in java mit den Alarmmanager, und in XE5 wird dieser in der TNotificationCenter gekapselt.

Hier der Beispielcode, der auch funktioniert - 10 Sekunden später wird der Alarm ausgelöst.
Nur für eine Weckerapp nicht praktikabel.
Um ein Jahr zu Wecken müsste ich beim Start der App 365 Notifications erzeugen


Meine Idee war nun, den nächsten Wecktermin (Notification := NotificationC.CreateNotification; ) in dem NotificationCReceiveLocalNotification event zu machen.
Würde theoretisch funktionieren, wenn das event eintreten würde. tut es aber nicht.

Also erster Alarm wird ausgelöst aber onReceiveLocalNotification wird dabei nicht ausgelöst.
Kann mir jemand erklären warum

Delphi-Quellcode:
procedure TNotificationsForm.btnSendScheduledNotificationClick(Sender: TObject);
var
  Notification: TNotification;
begin

  { verify if the service is actually supported }
  if NotificationC.Supported then
  begin
    Notification := NotificationC.CreateNotification;
    try
      Notification.Name := 'MyNotification';
      Notification.AlertBody := 'Delphi for Mobile is here!';
        Notification.HasAction:=true;
                Notification.EnableSound:=true;
      { Fired in 10 second }
      Notification.FireDate := Now + EncodeTime(0,0,10,0);

      { Send notification in Notification Center }
      NotificationC.ScheduleNotification(Notification);
    finally
      Notification.DisposeOf;
    end;
  end
end;
  Mit Zitat antworten Zitat