本文整理自网络,侵删。
//程序事件服务操作var FMXApplicationEventService: IFMXApplicationEventService;begin if TPlatformServices.Current.SupportsPlatformService (IFMXApplicationEventService, IInterface(FMXApplicationEventService)) then FMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent) else flag := false;end;
function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject) : boolean; begin if flag = false then exit; case AAppEvent of TApplicationEvent.aeEnteredBackground: begin //当程序后台运行了 end; end; Result := true;end;
//退出键操作procedure TPForm.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);begin if Key = vkHardwareBack then begin {$IFDEF ANDROID} MessageDlg('确认退出吗?', System.UITypes.TMsgDlgType.mtInformation, [ System.UITypes.TMsgDlgBtn.mbYes, //System.UITypes.TMsgDlgBtn.mbNo, System.UITypes.TMsgDlgBtn.mbCancel ], 0, System.UITypes.TMsgDlgBtn.mbCancel, procedure(const AResult: TModalResult) begin if AResult = mrYES then MainActivity.finish; { 退出程序 } // use FMX.Platform.Android end); {$ENDIF ANDROID} //close; Key := 0; exit; end;end;复制代码
博客园 滔Roy https://www.cnblogs.com/guorongtao
相关阅读 >>
[译]rad studio 10.4 新变化:面向控件的 vcl 样式管理
Delphi 使用 idhttp 获取 utf-8 编码的中文网页
Delphi Delphi 学习大师qq群讨论的字符串位置替换方法
Delphi ansicontainstext 是否包含子串
更多相关阅读请进入《Delphi》频道 >>