ios和android同步应用程序,如何在iOS和Android上获得应用恢复状态?

您需要使用

IFMXApplicationEventService注册一个回调,其中将通知应用程序:

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;

有关事件类型here的更多信息.

由PawełGłowacki主题的good article(对于Delphi XE5,但仍然有用).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值