Android JNI Bridge lazarus / 43-Android ---------------------------------------------------------------------- AliZairov · 2017-04-30 14:45 Hi. This example is the Delphi Android bridge system. 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 JavaInterfaces; interface uses  Androidapi.JNIBridge,  Androidapi.JNI.JavaTypes; type// ===== Forward declarations =====   JAppLibrary = interface;//com.zairovsoft.AppLibrary // ===== Interface declarations =====   JAppLibraryClass = interface(JObjectClass)    ['{3252901E-D765-4AC5-8FB7-FC7F2CA589C6}']    {class} function GetMsg(P1: JString): JString; cdecl;    {class} function init: JAppLibrary; cdecl;  end;   [JavaSignature('com/zairovsoft/AppLibrary')]  JAppLibrary = interface(JObject)    ['{B4900D81-BD6D-4163-AC93-A7A62C496A6C}']  end;  TJAppLibrary = class(TJavaGenericImport) end; implementation procedure RegisterTypes;begin  TRegTypes.RegisterType('JavaInterfaces.JAppLibrary', TypeInfo(JavaInterfaces.JAppLibrary));end; initialization  RegisterTypes;  end.  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 package com.zairovsoft; public class AppLibrary {        public static String GetMsg(String value)        {                return "AppLibrary: " + value;        }}  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 ShowMessage (JStringToString(TJAppLibrary.JavaClass.GetMsg(StringToJString(Edit1.T ext))));  This is more useful. How would such a similar structure for Pascal be? ---------------------------------------------------------------------- felipemdc · 2017-05-17 12:43 JNI is done in Free Pascal like this: http://wiki.lazarus.freepascal.org/Android_Programming#Android_JNI Does this answer your question? ---------------------------------------------------------------------- AliZairov · 2017-05-17 13:48 Hi. Thank you. I will examine. ---------------------------------------------------------------------- AliZairov · 2020-12-11 21:46 Hello. I didn't want to open a new topic. How do I do a dynamic structure 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 // Generated by JavaToPas v1.5 20150830 - 103113///////////////////////// ///////////////////////////////////////////////////////unit android.widget.Toast; interface uses  AndroidAPI.JNIBridge,  Androidapi.JNI.JavaTypes,  Androidapi.JNI.GraphicsContentViewText; type  JToast = interface;   JToastClass = interface(JObjectClass)    ['{3DA2EC00-C2D0-4434-A7F1-708100694351}']    function _GetLENGTH_LONG : Integer; cdecl;                                  //  A: $19    function _GetLENGTH_SHORT : Integer; cdecl;                               //  A: $19    function getDuration : Integer; cdecl;                                    // ()I A: $1    function getGravity : Integer; cdecl;                                       // ()I A: $1    function getHorizontalMargin : Single; cdecl;                               // ()F A: $1    function getVerticalMargin : Single; cdecl;                               // ()F A: $1    function getView : JView; cdecl;                                          // ()Landroid/view/View; A: $1    function getXOffset : Integer; cdecl;                                     // ()I A: $1    function getYOffset : Integer; cdecl;                                     // ()I A: $1    function init(context : JContext) : JToast; cdecl;                          // (Landroid/content/Context;)V A: $1    function makeText(context : JContext; resId : Integer; duration : Integer) : JToast; cdecl; overload;// (Landroid/content/Context;II)Landroid/widget/Toast; A: $9    function makeText(context : JContext; text : JCharSequence; duration : Integer) : JToast; cdecl; overload;// (Landroid/content/Context;Ljav a/lang/CharSequence;I)Landroid/widget/Toast; A: $9    procedure cancel ; cdecl;                                                   // ()V A: $1    procedure setDuration(duration : Integer) ; cdecl;                        // (I)V A: $1    procedure setGravity(gravity : Integer; xOffset : Integer; yOffset : Integer) ; cdecl;// (III)V A: $1    procedure setMargin(horizontalMargin : Single; verticalMargin : Single) ; cdecl;// (FF)V A: $1    procedure setText(resId : Integer) ; cdecl; overload;                       // (I)V A: $1    procedure setText(s : JCharSequence) ; cdecl; overload;                     // (Ljava/lang/CharSequence;)V A: $1    procedure setView(view : JView) ; cdecl;                                    // (Landroid/view/View;)V A: $1    procedure show ; cdecl;                                                   // ()V A: $1    property LENGTH_LONG : Integer read _GetLENGTH_LONG;                        // I A: $19    property LENGTH_SHORT : Integer read _GetLENGTH_SHORT;                      // I A: $19  end;   [JavaSignature('android/widget/Toast')]  JToast = interface(JObject)    ['{47C787A5-0B8C-4FFB-B2C5-E625822B718B}']    function getDuration : Integer; cdecl;                                    // ()I A: $1    function getGravity : Integer; cdecl;                                     // ()I A: $1    function getHorizontalMargin : Single; cdecl;                               // ()F A: $1    function getVerticalMargin : Single; cdecl;                               // ()F A: $1    function getView : JView; cdecl;                                          // ()Landroid/view/View; A: $1    function getXOffset : Integer; cdecl;                                       // ()I A: $1    function getYOffset : Integer; cdecl;                                     // ()I A: $1    procedure cancel ; cdecl;                                                 // ()V A: $1    procedure setDuration(duration : Integer) ; cdecl;                          // (I)V A: $1    procedure setGravity(gravity : Integer; xOffset : Integer; yOffset : Integer) ; cdecl;// (III)V A: $1    procedure setMargin(horizontalMargin : Single; verticalMargin : Single) ; cdecl;// (FF)V A: $1    procedure setText(resId : Integer) ; cdecl; overload;                       // (I)V A: $1    procedure setText(s : JCharSequence) ; cdecl; overload;                     // (Ljava/lang/CharSequence;)V A: $1    procedure setView(view : JView) ; cdecl;                                    // (Landroid/view/View;)V A: $1    procedure show ; cdecl;                                                   // ()V A: $1  end;   TJToast = class(TJavaGenericImport)  end; const  TJToastLENGTH_LONG = 1;  TJToastLENGTH_SHORT = 0; implementation end.  This code usage style is longer 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 Toast(instance: JObject; Str: JString; Duration: JInt);//const  //LENGTH_SHORT = 0;  //LENGTH_LONG = 1;var  env: PJNIEnv;  clz: JClass;  mtd, mtd2: JMethodID;  ptr: array[0..2] of JValue;  obj: JObject;begin  env := TJNIHelper.GetJNIEnv;  clz := TJNIHelper.GetClassID('android/widget/Toast');  mtd := TJNIHelper.GetStaticMethodID(clz, 'makeText', '(Landroid/content/Conte xt;Ljava/lang/CharSequence;I)Landroid/widget/Toast;');  //if (mtd = nil) then TLog.D('method not found'); exit;  ptr[0].l := instance;  ptr[1].l := Str;  ptr[2].i := Duration;  obj := env^^.CallStaticObjectMethodA(env, clz, mtd, @ptr);  mtd2 := TJNIHelper.GetMethodID(clz, 'show', '()V');  env^^.CallVoidMethod(env, obj, mtd2);end;  //Toast(instance, TJNIHelper.GetJString('CPU: ' + TJNIHelper.GetString(TAndroid.CPU)), 0);