When application goes to background we want keep counter lazarus / 43-Android ---------------------------------------------------------------------- Packs · 2023-07-01 18:15 When user minimise the application or he press the home button on device we would like the keep count of that ---------------------------------------------------------------------- Packs · 2023-07-03 12:45 Please help me ---------------------------------------------------------------------- BlueIcaro · 2023-07-03 16:17 Hi, I don't  is this works in Android, but in windows its works. Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, Forms, Controls, Graphics, Dialogs; type   { TForm1 }   TForm1 = class(TForm)     procedure FormCreate(Sender: TObject);   private     procedure Minimize(Sender: TObject);   public   end; var   Form1: TForm1;   Count: integer; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin   Application.OnMinimize := @Minimize;   Count := 0; end; procedure TForm1.Minimize(Sender: TObject); begin   Count := Count + 1;   Caption := IntToStr(Count); end; end. /BlueIcaro ---------------------------------------------------------------------- Packs · 2023-07-03 18:57 No my dear friend. I want to keep log off no of time user exit from the Android app ---------------------------------------------------------------------- Eugene Loza · 2023-07-04 11:51 I know there is a much better (native) solution, but I was unable to find it. So one potential workaround can be: add a Timer to your Form. Then update it e.g. every 0.1 seconds, and keep some memory of what was the last time of update. E.g. like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  LastUpdate: TDateTime;begin  if (Now - LastUpdate) * 24*60*60 > 1.0 then    WriteLn('App was offline for more than one second, resuming operation');  LastUpdate := Now;end; ---------------------------------------------------------------------- KodeZwerg · 2023-07-04 12:26 Does this do the trick? (tested only on Windows) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes , SysUtils , Forms , Controls , Graphics , Dialogs , StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Label1: TLabel;    procedure FormCreate(Sender: TObject);  strict private    FDeactivated: Integer;  private    procedure MyDeactivate(Sender: TObject);  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  Application.OnDeactivate := @MyDeactivate;  FDeactivated := 0;end; procedure TForm1.MyDeactivate(Sender: TObject);begin  Inc(FDeactivated);  Label1.Caption := IntToStr(FDeactivated);end; end. ---------------------------------------------------------------------- jmpessoa · 2023-07-04 17:08 Quoteor he press the home button on device we would like the keep count of that.... You can try handle  jForm "OnSpecialKeyDown" event to check for "home"  key... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.AndroidModule1SpecialKeyDown(Sender: TObject;  keyChar: char; keyCode: integer; keyCodeString: string; var mute: boolean);begin    if keyCode = 3 then        // 4 --> keyback       begin           ShowMessage(keyCodeString);    //HOME ...    end;end; ref: ---------------------------------------------------------------------- bytebites · 2023-07-04 17:33 How activity lifecycle is implemented in lamw? https://developer.android.com/guide/components/activities/activity- lifecycle ---------------------------------------------------------------------- jmpessoa · 2023-07-04 17:41 QuoteHow activity lifecycle is implemented in lamw? REF> https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/docs/LA MW_lifecycle_for_Android_activity.txt ---------------------------------------------------------------------- bytebites · 2023-07-04 17:54 How to catch onPause event for example? ---------------------------------------------------------------------- jmpessoa · 2023-07-04 18:34 QuoteHow to catch onPause event for example? Handling  "OnActivityPause"  in your app main form (TAndroidModule1) .... ---------------------------------------------------------------------- PeterEvans · 2023-07-04 22:48 I think the original question needs to be refined. If you are trying to establish if the user is still "active" and if they are not active then make them reenter their credentials, then another approach may be required. One way to do that is have the user regularly contact the server.