应用程序在iOS和Android上恢复状态

iOSAndroid上恢复应用程序时,是否有代码的angular度可以检查?

例如,当一个应用程序得到最小化和恢复(应用程序仍在设备的后台运行)。

谢谢,

您需要使用IFMXApplicationEventService来注册将通知应用程序的callback:

uses FMX.Types, FMX.Platform; function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean; begin case AAppEvent of TApplicationEvent.FinishedLaunching: Log.d('Launched.'); TApplicationEvent.BecameActive: Log.d('Gained focus.'); TApplicationEvent.EnteredBackground: Log.d('Now running in background.'); TApplicationEvent.WillBecomeForeground: Log.d('Restoring from background.'); TApplicationEvent.WillBecomeInactive: Log.d('Going to lose focus.'); TApplicationEvent.WillTerminate: Log.d('Quitting the application.'); TApplicationEvent.LowMemory: Log.d('Device running out of memory.'); // iOS only TApplicationEvent.TimeChange: Log.d('Significant change in time.'); TApplicationEvent.OpenURL: Log.d('Request to open an URL.'); end; Result := True; end; procedure TForm11.FormCreate(Sender: TObject); var aFMXApplicationEventService: IFMXApplicationEventService; begin if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent) else Log.d('Application Event Service not supported.'); end; 

有关这里的事件types的更多信息。

关于这个主题PawełGłowacki(Delphi XE5,但仍然有用)的好文章 。

在iOS中您可以添加标志

 applicationDidEnterBackground 

在appDelegate中知道用户是否进入了后台,

 applicationDidBecomeActive 

知道用户从后台返回到应用程序