{$IFDEF ANDROID}
MainActivity.finish;
{$ENDIF}
Delphi XE5 Android. Hardware back button press
-
29-06-2022 - |
Domanda
How simulate hardware back button press to close application?
I need close the application by code but Application.Terminate, Close, Hide and DisposeOf do not work.
So I thought to simulate hardware back button press to achieve my goal.
Soluzione
Altri suggerimenti
To make your application handle when users press the Back button on their Android device, add an event handler to your form for OnKeyUp, and use the following code within your event handler:
if Key = vkHardwareBack then
begin
// Do whatever you want to do here
Key := 0; // Set Key = 0 if you want to prevent the default action
end;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow