CJC Delphi 技巧馆's Archiver

cjc Posted at 2013-7-12 15:35

Detect when the Home Button is Pressed (检查IOS home键按下)

How do I detect when the Home Button is Pressed - I need an event


uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Platform;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
function AppEventHandler(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
var
AEService: IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService(StringToGUID('{F3AAF11A-1678-4CC6-A5BF-721A24A676FD}'),
IInterface(AEService)) then
AEService.SetApplicationEventHandler(AppEventHandler);
end;

function TForm1.AppEventHandler(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
begin
if AAppEvent = aeEnteredBackground then
begin
// This will be called if your app was active and the home button is pressed
end;
Result := True; // apparently this doesn't matter on iOS
end;

Page: [1]
CJC好玩背单词最新版本 - 是目前最好的背单词软件,游戏好玩,功能强大,词库众多,还有真人语音,免费下载,免费试用 !

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.