uses
.., FMX.Platform;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } function AppEventHandler(AppEvent: TApplicationEvent; AContext: TObject): Boolean; end;
FormCreate에서 어플의 이벤트서비스에 이벤트핸들러를 추가합니다.
procedure TForm1.FormCreate(Sender: TObject); var AppEventService: IFMXApplicationEventService; begin if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(AppEventService)) then begin AppEventService.SetApplicationEventHandler(AppEventHandler); end; end;
function TForm1.AppEventHandler(AppEvent: TApplicationEvent; AContext: TObject): Boolean; begin
with TApplicationEvent do
begin case AppEvent of //받아온 이벤트에 따라 처리합니다. FinishedLaunching: {To Do}; BecameActive: {To Do}; WillBecomeInactive: {To Do}; EnteredBackground: {To Do}; WillBecomeForeground: {To Do}; WillTerminate: {To Do}; LowMemory: {To Do}; TimeChange: {To Do}; OpenURL: {To Do}; end;
end; Result := True; end;
Description
Type of an application event.
An instance of TApplicationEvent may have any of the following values:
Item | Description | Platform | |
---|---|---|---|
Android | iOS | ||
| Your application has gained the focus. | Supported | Supported |
| The user is no longer using your application, but your application is still running in the background. | Supported | Supported |
| Your application has been launched. | Supported | Supported |
| This warns your application that the device is running out of memory. Your application should reduce memory usage, freeing structures and data that can be loaded again at a later point. | Supported | Supported |
| You application has received a request to open an URL. Application events of this type are usually associated with a context. This context is an instance of the iOS-only TiOSOpenApplicationContext.SourceApp is a string that contains the bundle ID of the application that requested your application to open the URL.TiOSOpenApplicationContext.URL is the URL to open, either a network resource or a file.TiOSOpenApplicationContext.Context is a pointer to a property-list object that might provide additional information.See the iOS API reference documentation for more information. | Supported | |
| There has been a significant change in time. This event might happen for example when the day changes or when the device changes to or from daylight savings time. | Supported | |
| The user is now using your application, which was previously in the background. | Supported | Supported |
| Your application is going to loose the focus. | Supported | Supported |
| The user is quitting your application. | Supported | Supported |
참조 : http://docwiki.embarcadero.com/Libraries/XE8/en/FMX.Platform.TApplicationEvent