gpt4 book ai didi

android - Firemonkey:如何检测操作系统(Android/iOS)何时关闭

转载 作者:行者123 更新时间:2023-12-03 22:59:04 25 4
gpt4 key购买 nike

我正在处理 Firemonkey (Delphi 10.4) 的以下问题:当 Android 操作系统将关闭并且我的应用程序仍在运行时,它不会触发 OnCloseQuery、OnClose 和 OnDestroy 事件。有没有办法检测或拦截操作系统关闭事件?当我使用方形按钮终止应用程序时会出现同样的问题(即当我使用方形按钮显示最近打开的应用程序并以这种方式关闭应用程序时)。
先感谢您。

最佳答案

我终于从一位 TMS 客户那里找到了解决方案 (肯兰德尔“Randall_Ken”活跃客户。)

uses FMX.Platform;

procedure TMyForm.FormCreate(Sender: TObject);
var
AppEventSvc: IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService
(IFMXApplicationEventService, IInterface(AppEventSvc)) then
begin
AppEventSvc.SetApplicationEventHandler(AppEvent);
end;
end;

function TMyForm.AppEvent(AAppEvent: TApplicationEvent;
AContext: TObject): Boolean;
begin
if AAppEvent = TApplicationEvent.WillTerminate then
begin
// Do soomething
end;
Result := true;
end;

关于android - Firemonkey:如何检测操作系统(Android/iOS)何时关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67514392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com