zoukankan      html  css  js  c++  java
  • Delphi XE5 android 捕获几个事件


    以下代码能监控到以下几个事件:

        FinishedLaunching 
        BecameActive 
        WillBecomeInactive
        EnteredBackground
        WillBecomeForeground
        WillTerminate
        LowMemory
        TimeChange
        OpenURL

    unit Unit11;
    
    interface
    
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts,
      FMX.Memo, FMX.Platform, FMX.StdCtrls;
    
    type
      TForm11 = class(TForm)
        Memo1: TMemo;
        ToolBar1: TToolBar;
        Label1: TLabel;
        procedure FormCreate(Sender: TObject);
      private
        procedure Log(s: string);
      public
        function HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
      end;
    
    var
      Form11: TForm11;
    
    implementation
    
    {$R *.fmx}
    
    { TForm11 }
    
    procedure TForm11.FormCreate(Sender: TObject);
    var aFMXApplicationEventService: IFMXApplicationEventService;
    begin
      if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then
        aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent)
      else
        Log('Application Event Service is not supported.');
    end;
    
    function TForm11.HandleAppEvent(AAppEvent: TApplicationEvent;
      AContext: TObject): Boolean;
    begin
      case AAppEvent of
        aeFinishedLaunching: Log('Finished Launching');
        aeBecameActive: Log('Became Active');
        aeWillBecomeInactive: Log('Will Become Inactive');
        aeEnteredBackground: Log('Entered Background');
        aeWillBecomeForeground: Log('Will Become Foreground');
        aeWillTerminate: Log('Will Terminate');
        aeLowMemory: Log('Low Memory');
        aeTimeChange: Log('Time Change');
        aeOpenURL: Log('Open URL');
      end;
      Result := True;
    end;
    
    procedure TForm11.Log(s: string);
    begin
      Memo1.Lines.Add(TimeToStr(Now) + ': ' + s);
    end;
    
    end.
    View Code
  • 相关阅读:
    图片在网页中不能显示
    利用QQWry.dat显示客户IP所在地 [转贴]
    asp.net时间戳与系统时间互转 mssql
    酷友网 http://www.kuiu.cn/ 再次上线了!!!
    string.Format .net string 补空
    ASP.net中md5加密码的方法[转]
    C#中|(位或)和||(逻辑或)有什么区别?
    .net身份证号码验证
    实用jquery代码片段集合
    ERROR: “System.Web.Mvc.Controller.File(string, string, string)”是一个“方法”
  • 原文地址:https://www.cnblogs.com/nywh2008/p/3393269.html
Copyright © 2011-2022 走看看