1 UnitUnit1;2 3 Interface4 5 uses6 system.sysutils, System.types, System.uitypes, system.classes, System.variants,7 FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs,8 FMX. Controls.presentation, Fmx.stdctrls;9 Ten type OneTForm1 =class(Tform) A Button1:tbutton; - Button2:tbutton; - Button3:tbutton; the Label1:tlabel; - Button4:tbutton; - Button5:tbutton; - Button6:tbutton; + procedureButton1Click (sender:tobject); - procedureButton2click (sender:tobject); + procedureButton3click (sender:tobject); A procedureFormkeyup (Sender:tobject;varKey:word;varKeychar:char; at shift:tshiftstate); - procedureButton4click (sender:tobject); - procedureButton6click (sender:tobject); - procedureButton5click (sender:tobject); - Private - {Private Declarations} in Public - {Public Declarations} to End; + - var the Form1:tform1; * $ ImplementationPanax Notoginseng uses - FMX. Platform.android, the FMX. Helpers.android, + Androidapi.JNI.Net, A Androidapi.JNI.GraphicsContentViewText, the Androidapi.JNI.JavaTypes, + Androidapi.helpers, - System. Ioutils; $ $ {$R *.FMX} - {$R *. NMXHDPIPH.FMX ANDROID} - {$R *. LGXHDPIPH.FMX ANDROID} the {$R *. MACINTOSH.FMX MACOS} - {$R *. XLGXHDPITB.FMX ANDROID}Wuyi {$R *. LGXHDPITB.FMX ANDROID} the {$R *. GGLASS.FMX ANDROID} - Wu procedureTform1.button1click (sender:tobject); - begin AboutLabel1.Text: ='pressing the back key will bring up a dialog box! '; $ End; - - procedureTform1.button2click (sender:tobject); - begin AMainactivity.finish;{Exit Program} + End; the - procedureTform1.button3click (sender:tobject); $ begin the {$IFDEF ANDROID} theApplication.MainForm.DisposeOf;{Exit Program} theHalt0); the {$ENDIF} - End; in the procedureTform1.button4click (sender:tobject); the var About intent:jintent; the begin theIntent: =TJIntent.JavaClass.init (TJIntent.JavaClass.ACTION_MAIN); the intent.addcategory (TJIntent.JavaClass.CATEGORY_HOME); + intent.setflags (TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); - sharedactivitycontext.startactivity (Intent); the End;Bayi the procedureTform1.button5click (sender:tobject); the begin - application.terminate; - End; the the procedureTform1.button6click (sender:tobject); the begin the Close; - End; the //This code error, not available, the reason is unknown. the procedureTform1.formkeyup (Sender:tobject;varKey:word;varKeychar:char; the shift:tshiftstate);94 begin the ifKey = Vkhardwareback Then//If you press the physical return key the begin theLabel1.Text: ='1';98 ifMessagedlg ('are you sure you want to quit? ', Tmsgdlgtype.mtconfirmation, About[Tmsgdlgbtn.mbok, Tmsgdlgbtn.mbcancel],-1) = Mrok Then -Mainactivity.finish;{Exit Program}101Key: =0;//Yes, or you'll quit if you press No.102 Exit;103 End;104 End; the 106 End.
Android Instance-Exit program (xe8+2)