delphi xe10 手机程序事件服务操作、退出键操作
2022-12-29 14:33:53 作者:admin
本文整理自网络,侵删。
//程序事件服务操作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
相关阅读 >>
Delphi fmx调用jar里的java类init方法
Delphi 取得文件夹及下一级文件夹下的文件列表
Delphi 判断文件路径,不存在则建立
Delphi treeview添加背景图片
用Delphi实现百度地图经纬度与地址互转
Delphi 用image 画图
Delphi 随机指定范围的字符串函数
Delphi d10.x 安卓app开发中按返回键后程序不退出程序的方法
Delphi中查找进程及强行结束进程的方法
Delphi下pos机控制钱箱,客显,打印机
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码