![]() |
Von angezeigter Notification zum Programm wechseln?
Hallo,
in einer Android-App zeige ich oben in der Taskleiste eine Notification an (z.B. 2 Stunden vor einem Termin). Nun möchte ich, wenn der Benutzer auf diese Notification klickt, das zugehörige Programm starten. Leider finde ich keinerlei Ansatz, wie das realisiert werden könnte :-( Ciao Stefan |
AW: Von angezeigter Notification zum Programm wechseln?
ich poste mal einfach etwas Quellcode. Der fett gedruckte Teil ist das, was du suchst.
Delphi-Quellcode:
hier die beiden Zeilen, die für dich hauptsächlich interessant sind:
procedure TFormX.HandleAlert;
var //Notifications: MyNotification:TNotification; begin MyNotification:=NotificationCenter1.CreateNotification; MyNotification.Name:='Message'; //taucht auf Android nicht auf MyNotification.Title:='Notification'; //Taucht als Titelzeile (fett) auf //AlertBody ist für iOS obligatorisch MyNotification.AlertBody:='Alarmmeldung!'; //taucht als 2. Zeile (nicht fett) auf MyNotification.Number:=usercfg.n_notifications; //funktioniert i-wie nicht wie erwartet MyNotification.EnableSound:=false; {$IFDEF iOS} //nur für iOS? NotificationCenter1.ApplicationIconBadgeNumber:=usercfg.n_notifications; {$ENDIF}
Delphi-Quellcode:
und noch der Rest der Procedure
//beim Klicken auf die Notification soll sich die App öffnen:
MyNotification.HasAction := True; MyNotification.AlertAction := 'Open App';
Delphi-Quellcode:
Ich hoffe, es hilft und funzt :)
//ZUM SCHLUSS ABSCHICKEN
//Anzeige mit gesetztem Firedate //z.B. Fired in 10 seconds: MyNotification.FireDate := Now + EncodeTime(0, 0, 10, 0); //MyNotification.FireDate:=now; //NotificationCenter1.ScheduleNotification(MyNotification); //sofortige Anzeige try NotificationCenter1.PresentNotification(MyNotification); finally MyNotification.DisposeOf; end; end; |
AW: Von angezeigter Notification zum Programm wechseln?
Hallo Wolfgang,
vielen Dank, das
Delphi-Quellcode:
war genau der fehlende Punkt :-)
//beim Klicken auf die Notification soll sich die App öffnen:
MyNotification.HasAction := True; MyNotification.AlertAction := 'Open App'; Ciao Stefan |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:45 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz