Difference between revisions of "Android Interface/Native Android GUI"

From Lazarus wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{Platform only|Android|Android|Android}}
 
Go back to [[Android Interface]]
 
Go back to [[Android Interface]]
  
Line 14: Line 15:
 
By default the program will restart on orientation change, on keyboard change, and in a lot of other cases. This is usually unwanted. To disable program restart on keyboard showing and orientation changed add this to the manifest file:
 
By default the program will restart on orientation change, on keyboard change, and in a lot of other cases. This is usually unwanted. To disable program restart on keyboard showing and orientation changed add this to the manifest file:
  
<code>
+
<syntaxhighlight lang=pascal>
 
   <activity
 
   <activity
 
     ...
 
     ...
 
     android:configChanges="orientation|keyboardHidden"
 
     android:configChanges="orientation|keyboardHidden"
</code>
+
</syntaxhighlight>
  
 
See also:
 
See also:
Line 38: Line 39:
 
====Timer example====
 
====Timer example====
  
<delphi>
+
<syntaxhighlight lang=pascal>
 
program turbochessclock4android;
 
program turbochessclock4android;
  
Line 76: Line 77:
 
   // ...
 
   // ...
 
end.
 
end.
</delphi>
+
</syntaxhighlight>
  
[http://www.prlog.org/11289974-phone-number-lookup-verizon-phone-number-reverse-lookup-to-get-information-you-need-quickly.html reverse lookup]
+
[[Category:Android]]
 
 
[http://thetvtopc.com/Reverse_Cell_Phone_Lookup_Number reverse phone lookup cell]
 

Latest revision as of 08:17, 9 February 2020

Android robot.svg

This article applies to Android only.

See also: Multiplatform Programming Guide

Go back to Android Interface

Android4Pascal

See the page about Android4Pascal, which is the bindings between Pascal programs and the Android Java APIs.


Manifest configuration

Control the program restart

By default the program will restart on orientation change, on keyboard change, and in a lot of other cases. This is usually unwanted. To disable program restart on keyboard showing and orientation changed add this to the manifest file:

  <activity
     ...
     android:configChanges="orientation|keyboardHidden"

See also:

Resource files

Guidelines for the Icons

Read here: http://developer.android.com/guide/practices/ui_guidelines/icon_design.html

Using other APIs

Using the Timer

The Android API bindings include a handy timer control called TAndroidTimer. It works just like a Runnable, and inside it a Handler class is utilized to run the Runnable in the main GUI thread so that event executed in this timer can call Android APIs.

Timer example

program turbochessclock4android;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils, androidpipescomm, androidview, javalang,
  androidapp, androidtimer;//, gles11;

type
  TEventHandler = class
  public
    procedure HandleOnTimer(ASender: TObject);
    procedure buttonClickCallback(v: TView);
  end;

var
  //...
  TimerCount: Integer = 0;
  MyTimer: TAndroidTimer;
  MyEventHandler: TEventHandler;

procedure TEventHandler.buttonClickCallback(v: TView);
begin
  MyTimer.postDelayed(100);
end;

procedure TEventHandler.HandleOnTimer(ASender: TObject);
begin
  Inc(TimerCount);
  tv.setText(Format('Timer event #%d', [TimerCount]));
  MyTimer.postDelayed(1000);
end;

begin
  MyEventHandler := TEventHandler.Create;
  // ...
end.