Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi X5 Android TNotificationCenter (https://www.delphipraxis.net/177047-delphi-x5-android-tnotificationcenter.html)

Rudirabbit 12. Okt 2013 18:10

Delphi X5 Android TNotificationCenter
 
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 :wall::wall:

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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:09 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz