Catch Lock Screen Event

  

Good day. I am writing in C ++ Builder in Embarcadero Xe8. I do mobile application project on Ios and android and faced such problem: I can not catch the phone lock screen event. I used to always do so:

bool TForm1::HandleApp(TApplicationEvent a, TObject *x)
{
if (a == TApplicationEvent::EnteredBackground)
{
MediaPlayer1->Stop();
}
return true;
}
//—————————————————————————
void __fastcall TForm1::FormCreate(TObject *Sender)
{
_di_IFMXApplicationEventService a;
if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXApplicationEventService), &a))
{
a->SetApplicationEventHandler(TForm1::HandleApp);
}
}

But an error:

\Unit1.cpp(33): cannot initialize a parameter of type ‘TApplicationEventHandler’ (aka ‘bool (closure *)(Fmx::Platform::TApplicationEvent, System::TObject __borland_class *__strong) __attribute((pcs(“aapcs-vfp”)))’) with an lvalue of type ‘bool (__closure *)(Fmx::Platform::TApplicationEvent, System::TObject __borland_class *__strong)’
FMX.Platform.hpp(252): passing argument to parameter ‘AEventHandler’ here

I Do not know what else to try to do! Could you please help me?

Comments are closed.