애플리케이션 이벤트핸들러를 등록하면 앱의 라이프 사이클 이벤트를 수신할 수 있습니다.


먼저 상단(interface) uses절에 FMX.Platform을 추가 후 이벤트 수신 용 이벤트를 아래와 같이 작성합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function TForm1.AppEventHandler(AAppEvent: TApplicationEvent;
  AContext: TObject): Boolean;
begin
  Result := False;
  case AAppEvent of
    TApplicationEvent.FinishedLaunching: Log.d('FinishedLaunching');
    TApplicationEvent.BecameActive: Log.d('BecameActive');
    TApplicationEvent.WillBecomeInactive: Log.d('WillBecomeInactive');
    TApplicationEvent.EnteredBackground: Log.d('EnteredBackground');
    TApplicationEvent.WillBecomeForeground: Log.d('WillBecomeForeground');
    TApplicationEvent.WillTerminate: Log.d('WillTerminate');
    TApplicationEvent.LowMemory: Log.d('LowMemory');
    TApplicationEvent.TimeChange: Log.d('TimeChange');
    TApplicationEvent.OpenURL: Log.d('OpenURL');
  end;
end;

메인 폼 생성 시 이벤트 핸들러를 등록(SetApplicationEventHandler)합니다.

1
2
3
4
5
6
7
8
9
procedure TForm1.FormCreate(Sender: TObject);
var
  AEService: IFMXApplicationEventService;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(AEService)) then
  begin
    AEService.SetApplicationEventHandler(AppEventHandler);
  end;
end;

아래 이벤트를 참고해 필요한 항목에 이벤트 발생 시 코드를 추가하세요.


애플리케이션 이벤트 플랫폼 별 지원 여부

 이벤트

 설명

 안드로이드 지원

 iOS 지원

 BecomeActive

 애플리케이션이 활성화 되었습니다.

 지원

 지원 

 EnteredBackground

 애플리케이션이 백그라운드로 진입했습니다.

 지원

 지원

 FinishedLaunching

 애플리케이션이 시작되었습니다.

 지원

 지원

 LowMemory

 디바이스 메모리가 부족하다는 경고입니다. 내부 메모리 사용량을 줄이세요.

 지원

 지원

 OpenURL

 url 요청을 받았습니다.

 X

 지원

 TimeChange

 시간에 큰 변화가 발생. 하루가 바뀐 경ㅇ나 서머타임이 시작 또는 끝난 경우 발생

 X

 지원

 WillBecomeForeground

 백그라운드의 애플리케이션이 활성화 되었습니다.

 지원

 지원

 WillBecomeInactive

 다른 애플리케이션이 활성화 되었습니다.

 지원

 지원

 WillTerminate

 사용자가 애플리케이션을 종료합니다.

 지원

 지원


안드로이드 라이프사이크

http://developer.android.com/reference/android/app/Activity.html


iOS 라이프사이크


https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html


참고 글

번호 제목 글쓴이 날짜 조회 수
공지 [DelphiCon 요약] 코드사이트 로깅 실전 활용 기법 (Real-world CodeSite Logging Techniques) 관리자 2021.01.19 14389
공지 [UX Summit 요약] 오른쪽 클릭은 옳다 (Right Click is Right) 관리자 2020.11.16 13023
공지 [10.4 시드니] What's NEW! 신기능 자세히 보기 관리자 2020.05.27 15532
공지 RAD스튜디오(델파이,C++빌더) - 고객 사례 목록 관리자 2018.10.23 21064
공지 [데브기어 컨설팅] 모바일 앱 & 업그레이드 마이그레이션 [1] 관리자 2017.02.06 22297
공지 [전체 목록] 이 달의 기술자료 & 기술레터 관리자 2017.02.06 17933
공지 RAD스튜디오(델파이, C++빌더) - 시작하기 [1] 관리자 2015.06.30 38228
공지 RAD스튜디오(델파이,C++빌더) - 모바일 앱 개발 사례 (2020년 11월 업데이트 됨) 험프리 2014.01.16 173741
1398 N 윈도우와 맥 개발 시작을 위한 파이어몽키 코스북: 무료 다운로드 제공(385페이지) 관리자 2013.04.05 152319
1397 ComPort(시리얼 통신) 컴포넌트 설치안내 [11] file 험프리 2013.12.04 106658
1396 [REST API] REST 기반 파일 업로드와 다운로드 구현하기 험프리 2020.08.31 82865
1395 델파이 튜토리얼 자습서 이용 안내 관리자 2014.09.01 71931
1394 이 달의 기술자료 - 2014년 11월 험프리 2014.10.13 54111
1393 이 달의 기술자료 - 2014년 6월 file 험프리 2014.06.05 50343
1392 Find the O/S Language Type c2design 2014.07.30 47677
1391 RAD Studio Resource Center 박병일 2012.01.26 46441
1390 CD-ROM 열고 닫기 박병일 2011.12.22 44760
1389 [Android] 폰번호 가져오기 [1] 타락천사 2014.09.05 38518
1388 이 달의 기술자료 - 2014년 12월 file 험프리 2014.11.26 32446
1387 RAD Studio XE6 Update1 발표 [1] Humphery 2014.06.20 29459
1386 델파이XE2 파이어몽키 기반 아이폰앱 개발에서 제스춰를 인식시키는 방법 박병일 2012.01.25 23241
1385 [10.4 시드니 신기능] 새로운 VCL TEdgeBrowser 컴포넌트 험프리 2020.05.18 22880
1384 SendMessage 함수를 이용한 메세지 전송 관리자 2012.01.05 18248