Android Instance-Exit program

Source: Internet
Author: User

Android Instance-Exit program Http://www.cnblogs.com/FKdelphi

UnitUnit1;Interfaceusessystem.sysutils, System.types, System.uitypes, system.classes, System.variants, FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, FMX. Controls.presentation, Fmx.stdctrls;typeTForm1=class(tform) Button1:tbutton;    Button2:tbutton;    Button3:tbutton;    Label1:tlabel;    Button4:tbutton;    Button5:tbutton;    Button6:tbutton; procedureButton1Click (Sender:tobject); procedureButton2click (Sender:tobject); procedureButton3click (Sender:tobject); procedureFormkeyup (Sender:tobject;varKey:word;varKeychar:char;    Shift:tshiftstate); procedureButton4click (Sender:tobject); procedureButton6click (Sender:tobject); procedureButton5click (Sender:tobject); Private    {Private Declarations}   Public    {Public Declarations}  End;varForm1:tform1;ImplementationusesFMX. PLATFORM.ANDROID,FMX. Helpers.android,androidapi.jni.net,androidapi.jni.graphicscontentviewtext,androidapi.jni.javatypes, Androidapi.helpers,system. Ioutils;{$R *.FMX}{$R *. NMXHDPIPH.FMX ANDROID}{$R *. LGXHDPIPH.FMX ANDROID}{$R *. MACINTOSH.FMX MACOS}{$R *. XLGXHDPITB.FMX ANDROID}{$R *. LGXHDPITB.FMX ANDROID}{$R *. GGLASS.FMX ANDROID}procedureTform1.button1click (sender:tobject);beginLabel1.Text:='pressing the back key will bring up a dialog box! ';End;procedureTform1.button2click (sender:tobject);beginMainactivity.finish;{Exit Program}End;procedureTform1.button3click (sender:tobject);begin  {$IFDEF ANDROID}Application.MainForm.DisposeOf;{Exit Program}Halt (0); {$ENDIF}End;procedureTform1.button4click (sender:tobject);varintent:jintent;beginIntent:=TJIntent.JavaClass.init (TJIntent.JavaClass.ACTION_MAIN);  Intent.addcategory (TJIntent.JavaClass.CATEGORY_HOME);  Intent.setflags (TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); Sharedactivitycontext.startactivity (Intent);End;procedureTform1.button5click (sender:tobject);beginapplication.terminate;End;procedureTform1.button6click (sender:tobject);beginClose;End;//This code error, not available, the reason is unknown. procedureTform1.formkeyup (Sender:tobject;varKey:word;varKeychar:char; Shift:tshiftstate);begin  ifKey = Vkhardwareback Then//If you press the physical return key  beginLabel1.Text:='1'; ifMessagedlg ('are you sure you want to quit? ', Tmsgdlgtype.mtconfirmation, [Tmsgdlgbtn.mbok, Tmsgdlgbtn.mbcancel],-1) = Mrok ThenMainactivity.finish;{Exit Program}Key:=0;//Yes, or you'll quit if you press No.Exit; End;End;End.

Android Instance-Exit program

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.