AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Cross-Platform-Entwicklung Auslesen ob die App (Android/iOS im Vordergrund läuft
Thema durchsuchen
Ansicht
Themen-Optionen

Auslesen ob die App (Android/iOS im Vordergrund läuft

Ein Thema von DaCoda · begonnen am 22. Jul 2022 · letzter Beitrag vom 22. Jul 2022
 
DaCoda

Registriert seit: 21. Jul 2006
Ort: Hamburg
165 Beiträge
 
Delphi 12 Athens
 
#5

AW: Auslesen ob die App (Android/iOS im Vordergrund läuft

  Alt 22. Jul 2022, 20:42
Ich habe es jetzt so gelöst:

Code:
{* im uses Abschnitt *}
uses
  FMX.Platform;

{im TForm-Abschnitt *}
  procedure FormCreate(Sender: TObject);
private
  AppIsEnabled: Boolean;
  function HandleAppEvent(   AAppEvent : TApplicationEvent;  AContext : TObject ) : Boolean;

[* im Implementation - Abschnitt *}
procedure TfrmMain.FormCreate(Sender: TObject);
var
  SvcEvents : IFMXApplicationEventService;
begin
    if TPlatformServices.Current.SupportsPlatformService
      ( IFMXApplicationEventService, IInterface( SvcEvents ) )
    then
      SvcEvents.SetApplicationEventHandler( HandleAppEvent );
end;


function TfrmMain.HandleAppEvent(   AAppEvent : TApplicationEvent;  AContext : TObject ) : Boolean;
begin
    case AAppEvent of
      TApplicationEvent.FinishedLaunching : ;
      TApplicationEvent.BecameActive : AppIsEnabledEnabled := True;
      TApplicationEvent.WillBecomeInactive : ;
      TApplicationEvent.EnteredBackground : AppIsEnabled := False;
      TApplicationEvent.WillBecomeForeground : ;
      TApplicationEvent.WillTerminate : ;
      TApplicationEvent.LowMemory : ;
      TApplicationEvent.TimeChange : ;
      TApplicationEvent.OpenURL : ;
    end;
    Result := True;
end;
Scheint so korrekt zu funktionieren, vielleicht kann es ja mal jemand brauchen.

Lieben Dank für Eure Tipps!
Debuggers don’t remove bugs, they only show them in slow-motion.

Geändert von DaCoda (22. Jul 2022 um 20:44 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:17 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 by Thomas Breitkreuz