Lazarus

Programming => Operating Systems => Android => Topic started by: jmpessoa on September 01, 2013, 04:35:04 pm

Title: Android Module Wizard
Post by: jmpessoa on September 01, 2013, 04:35:04 pm
   Lazarus Android Module Wizard
                 "Form Designer and Components development model!"
      
   "A wizard to create JNI Android loadable module (.so) in Lazarus/Free Pascal using
   [datamodule like] Form Designer and Components!"

   Author: Jose Marques Pessoa : jmpessoa__hotmail_com

      https://github.com/jmpessoa/lazandroidmodulewizard

Please, to start:
   "readme.txt"
   "install_tutorial_ant_users.txt"
   "install_tutorial_eclipse_users.txt"

Acknowledgements: Eny and Phil for the Project wizard hints...
                  http://forum.lazarus.freepascal.org/index.php/topic,20763.msg120823.html#msg120823

                  Felipe for Android support....

                  TrueTom for Laz4Android Package (laz4android1.1-41139)...
                  https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6%21149

                  Lazarus forum community!

version 0.1 - August 2013

[1]Warning: at the moment this code is just a *proof-of-concept*

I. INSTALL LAZARUS PACKAGE (laz4android1.1-41139)

   1. From lazarus IDE

      1.1 Package -> Open Package -> "lazandroidwizardpack.lpk"
   
      1.2 From Package Wizard
          1.2.1 Compile
          1.2.2 Use -> Install

II. USE

1. From Eclipse IDE

  1.1. File -> New -> Android Application Project

  1.2. From Package Explore -> src
   
       Right click your recent created package -> new -> class 
   
       Enter new class name... (ex. JNIHello)
   
       Edit class code for wrapper native methods (ex...)

Code: [Select]

                package org.jmpessoa.app1;
 
public class JNIHello {

   public native String getString(int flag);
   public native int getSum(int x, int y);

                   static {
try {
          System.loadLibrary("jnihello");           
} catch(UnsatisfiedLinkError ule) {
    ule.printStackTrace();
}
                   }
             } 


  1.3. warning: System.loadLibrary("...") must match class Name lower case...
       ex. JNIHello -> "jnihello"

2. From lazarus IDE (laz4android1.1-41139)

   2.1 Project -> New Project
   2.2 JNI Android Module

2.1. From JNI Android Module set Paths
   2.1.1 Path to Eclipse Workspace
       ex. C:\adt32\eclipse\workspace
           
   2.1.2 Path to Ndk Plataforms
       ex. C:\adt32\ndk7\platforms\android-8\arch-arm\usr\lib
 
   2.1.3 Path to Ndk Toolchain 
       ex. C:\adt32\ndk7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.4.3

2.2. From JNI Android Module select Java wrapper class for native methods.... (ex JNIHello)

2.3. OK! 

2.3.1 - Data Module Form Code:

Code: [Select]
{Hint: save all files to location: C:\adt32\eclipse\workspace\App1\jni }
unit unit1;
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils;
 
type
  TAndroidModule1 = class(TDataModule)
    private
      {private declarations}
    public
      {public declarations}
  end;
 
var
  AndroidModule1: TAndroidModule1;

implementation
 
{$R *.lfm}
 
end.

2.3.2. Library Code:
Code: [Select]
{hint: save all files to location: C:\adt32\eclipse\workspace\App1\jni }
library jnihello;
 
{$mode delphi}
 
uses
  Classes, SysUtils, CustApp, jni, Unit1;
 
const
  curClassPathName: string='';
  curClass: JClass=nil;
  curVM: PJavaVM=nil;
  curEnv: PJNIEnv=nil;
 
type
 
  TAndroidApplication = class(TCustomApplication)
   public
     procedure CreateForm(InstanceClass: TComponentClass; out Reference);
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
  end;
 
procedure TAndroidApplication.CreateForm(InstanceClass: TComponentClass; out Reference);
var
  Instance: TComponent;
begin
  Instance := TComponent(InstanceClass.NewInstance);
  TComponent(Reference):= Instance;
  Instance.Create(Self);
end;
 
constructor TAndroidApplication.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  StopOnException:=True;
end;
 
destructor TAndroidApplication.Destroy;
begin
  inherited Destroy;
end;
 
var
  Application: TAndroidApplication;
 
{ Class:     org_jmpessoa_app1_JNIHello
  Method:    getString
  Signature: (I)Ljava/lang/String; }
function getString(PEnv: PJNIEnv; this: JObject; flag: JInt): JString; cdecl;
begin
  {your code....}
  {Result:=;}
end;

{ Class:     org_jmpessoa_app1_JNIHello
  Method:    getSum
  Signature: (II)I }
function getSum(PEnv: PJNIEnv; this: JObject; x: JInt; y: JInt): JInt; cdecl;
begin
  {your code....}
  {Result:=;}
end;

const NativeMethods:array[0..1] of JNINativeMethod = (
   (name:'getString';
    signature:'(I)Ljava/lang/String;';
    fnPtr:@getString;),
   (name:'getSum';
    signature:'(II)I';
    fnPtr:@getSum;)
);

function RegisterNativeMethodsArray(PEnv: PJNIEnv; className: PChar; methods: PJNINativeMethod; countMethods:integer):integer;
begin
  Result:= JNI_FALSE;
  curClass:= (PEnv^).FindClass(PEnv, className);
  if curClass <> nil then
  begin
    if (PEnv^).RegisterNatives(PEnv, curClass, methods, countMethods) > 0 then Result:= JNI_TRUE;
  end;
end;
 
function RegisterNativeMethods(PEnv: PJNIEnv): integer;
begin
  curClassPathName:= 'org/jmpessoa/app1/JNIHello';
  Result:= RegisterNativeMethodsArray(PEnv, PChar(curClassPathName), @NativeMethods[0], Length(NativeMethods));
end;
 
function JNI_OnLoad(VM: PJavaVM; reserved: pointer): JInt; cdecl;
var
  PEnv: PPointer {PJNIEnv};
begin
  PEnv:= nil;
  Result:= JNI_VERSION_1_6;
  (VM^).GetEnv(VM, @PEnv, Result);
  if PEnv <> nil then RegisterNativeMethods(PJNIEnv(PEnv));
  curVM:= VM {PJavaVM};
  curEnv:= PJNIEnv(PEnv);
end;
 
procedure JNI_OnUnload(VM: PJavaVM; reserved: pointer); cdecl;
begin
  if curEnv <> nil then (curEnv^).UnregisterNatives(curEnv, curClass);
  curClass:= nil;
  curEnv:= nil;
  curVM:= nil;
  Application.Terminate;
  FreeAndNil(Application);
end;

exports
  JNI_OnLoad name 'JNI_OnLoad',
  JNI_OnUnload name 'JNI_OnUnload',
  getString name 'Java_org_jmpessoa_app1_JNIHello_getString',
  getSum name 'Java_org_jmpessoa_app1_JNIHello_getSum';
 
begin
  Application:= TAndroidApplication.Create(nil);
  Application.Title:= 'My Android Library';
  Application.Initialize;
  Application.CreateForm(TAndroidModule1, AndroidModule1);
end.

2.4. follow the code hint: "save all files to location....."

2.5. From Lazarus IDE (laz4android1.1-41139)
     Run -> Build

III. BUILD AND RUN ANDROID APPLICATION

     1.  From Eclipse IDE

     1.1 right click your recent created project -> Run as -> Android Application

IV.  GIT HUB

     https://github.com/jmpessoa/lazandroidmodulewizard

     To facilitate follows first code release on attachment (*.rar) and some interface pictures...

     Have Fun!
Title: Re: Android Module Wizard
Post by: jmpessoa on September 11, 2013, 05:27:16 pm
Hi There,

I made some improvements on parse (and bug fix  :-[).

Now Java method signature like this:

Code: [Select]
public native int getGraphics(ByteBuffer graphicsBuffer, int w, int h);   

Is handled correctly:

Code: [Select]
{ Class:     org_jmpessoa_pascalgraphics_GraphicsBoard
  Method:    getGraphics
  Signature: (Ljava/nio/ByteBuffer;II)I }

function getGraphics(PEnv: PJNIEnv; this: JObject; graphicsBuffer: JObject; w: JInt; h: JInt): JInt; cdecl;
begin

end;

Code: [Select]
const NativeMethods:array[0..0] of JNINativeMethod = (
   (name:'getGraphics';
    signature:'(Ljava/nio/ByteBuffer;II)I';
    fnPtr:@getGraphics;)
);

Follows some example picture..... and the package (*.rar)

Greetings!

https://github.com/jmpessoa/lazandroidmodulewizard
Title: Re: Android Module Wizard
Post by: engkin on October 10, 2013, 04:28:33 pm
Thank you for sharing your code.   :) It did help me learn a few things like Lazarus project wizards and  Android ARM v7 needed compiler options.

I had only one simple problem using it due to hard-coded path "C:\adt32\eclipse\workspace" in:

uformandroidproject.pas (FormAndroidProject) --> ShellTreeView1 --> Root

it worked after creating these folders and allowed my to change it to my actual folder  ;D

While working on your wizard did you have to re-build Lazarus every time you made a small change? or am I missing something?  ::)

Is it possible to use Build Modes to add compiler settings for both Arm v6 and v7 and maybe i386 to the same project using your project wizard?

Thanks again.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 10, 2013, 05:09:09 pm
Hi engkin, thank you!

Actually when you modify a package you need re-install (this is
a Lazarus question)...

Hint: for install and re-intall package in Lazarus4Android close any cross-compile-android project and open a window project!

Please get  more updated version from:

https://github.com/jmpessoa/lazandroidmodulewizard

I will fix the hard path today!

Sorry, I have not learned about Build Modes... :-[

Greetings!
Title: Re: Android Module Wizard
Post by: picstart on October 10, 2013, 06:04:35 pm
With the risk of being shot as the messenger...this development is the the lifeboat for Lazarus.
Android is a significant market and is growing. Future apps will be on handheld devices. Lazarus needs a robust path to Android. Many have given up already on Lazarus sure they could spend weeks trying to get Lazarus  to compile a single app but it is smarter to go another route. The originator of this smart approach admits the reason for this direction is that they realized the futility of the existing approach. This effort is trying to bring smart back and bury the obtuse solutions offered to date. Smart work!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 10, 2013, 08:26:42 pm
Hi All,

At the moment I am working hard to bring

Android Controls for Lazarus  by simonsayz

(http://forum.lazarus.freepascal.org/index.php/topic,22079.0.html)
 
to talk with my Android Module Wizard.... follows some figures.

Thanks to all!

Title: Re: Android Module Wizard
Post by: Leledumbo on October 14, 2013, 12:06:11 am
Quote
At the moment I am working hard to bring

Android Controls for Lazarus  by simonsayz
That looks delicious, I'll be waiting...
Title: Re: Android Module Wizard
Post by: jmpessoa on November 17, 2013, 03:32:36 pm
Hi All,

I can already anticipate some information about what we're talking about: very little code, just design ( without form design) ... that is: component model, LazAndroidWizard and  Object Inspector does the task....

The first part of my task is almost ready .... I hope to make available my code very soon!

Follow some results just for curiosity ...

happy Sunday day!


*.lfm
Code: [Select]
object AndroidModule6: TAndroidModule6
  OnCreate = DataModuleCreate
  OldCreateOrder = False
  BackButton = True
  Title = 'jForm'
  BackgroundColor = colbrBlack
  OnCloseQuery = DataModuleCloseQuery
  OnRotate = DataModuleRotate
  OnJNIPrompt = DataModuleJNIPrompt
  Height = 443
  HorizontalOffset = 319
  VerticalOffset = 145
  Width = 224
  object jTextView1: jTextView
    Id = 26515
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrYellow
    FontSize = 0
    Text = 'List View Demo'
    left = 104
    top = 24
  end
  object jTextView2: jTextView
    Id = 36024
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrSilver
    FontSize = 0
    Text = 'Enter New Item:'
    left = 48
    top = 96
  end
  object jEditText1: jEditText
    Id = 53166
    Anchor = jTextView2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpTwoThirdOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Alignment = taLeft
    InputTypeEx = itxText
    LineMaxLength = 360
    Visible = True
    BackgroundColor = colbrWhite
    FontColor = colbrDefault
    FontSize = 0
    SingleLine = True
    ScrollBarStyle = scrNone
    MaxLines = 1
    HorScrollBar = False
    VerScrollBar = False
    WrappingLine = True
    left = 48
    top = 152
  end
  object jButton1: jButton
    Id = 0
    Anchor = jEditText1
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneThirdOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'Add'
    FontColor = colbrLightSteelBlue
    FontSize = 0
    OnClick = jButton1Click
    left = 144
    top = 152
  end
  object jEditText2: jEditText
    Id = 80017
    Anchor = jTextView3
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneThirdOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Alignment = taLeft
    InputTypeEx = itxText
    LineMaxLength = 360
    Visible = True
    BackgroundColor = colbrWhite
    FontColor = colbrDefault
    FontSize = 0
    SingleLine = True
    ScrollBarStyle = scrNone
    MaxLines = 1
    HorScrollBar = False
    VerScrollBar = False
    WrappingLine = True
    left = 48
    top = 320
  end
  object jTextView3: jTextView
    Id = 5036
    Anchor = jListView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrSilver
    FontSize = 0
    Text = 'Enter Item Index:'
    left = 48
    top = 264
  end
  object jButton2: jButton
    Id = 63804
    Anchor = jEditText2
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpTwoThirdOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'Delete'
    FontColor = colbrLightSteelBlue
    FontSize = 0
    OnClick = jButton2Click
    left = 144
    top = 320
  end
  object jListView1: jListView
    Id = 8951
    Anchor = jEditText1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpOneThirdOfParent
    MarginLeft = 10
    MarginTop = 0
    MarginRight = 10
    MarginBottom = 0
    Items.Strings = (
      'Lazarus'
      'Pascal'
      'Android'
    )
    Visible = True
    BackgroundColor = colbrLightSteelBlue
    FontColor = colbrRed
    FontSize = 0
    OnClickItem = jListView1ClickItem
    left = 96
    top = 208
  end
  object jButton3: jButton
    Id = 0
    Anchor = jEditText2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'ListView Items Clear '
    FontColor = colbrLightSteelBlue
    FontSize = 0
    OnClick = jButton3Click
    left = 96
    top = 376
  end
end

*.pas
Code: [Select]
{Hint: save all files to location: \jni }
unit unit6;
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls;
 
type

  { TAndroidModule6 }

  TAndroidModule6 = class(jForm)
      jButton1: jButton;
      jButton2: jButton;
      jButton3: jButton;
      jEditText1: jEditText;
      jEditText2: jEditText;
      jListView1: jListView;
      jTextView1: jTextView;
      jTextView2: jTextView;
      jTextView3: jTextView;
      procedure DataModuleCloseQuery(Sender: TObject; var CanClose: boolean);
      procedure DataModuleCreate(Sender: TObject);
      procedure DataModuleJNIPrompt(Sender: TObject);
      procedure DataModuleRotate(Sender: TObject; rotate: integer;
        var rstRotate: integer);
      procedure jButton1Click(Sender: TObject);
      procedure jButton2Click(Sender: TObject);
      procedure jButton3Click(Sender: TObject);
      procedure jListView1ClickItem(Sender: TObject; Item: Integer);
    private
      {private declarations}
    public
      {public declarations}
  end;
 
var
  AndroidModule6: TAndroidModule6;

implementation
 
{$R *.lfm}

{ TAndroidModule6 }

procedure TAndroidModule6.DataModuleCloseQuery(Sender: TObject;
  var CanClose: boolean);
begin
   CanClose:= True;
end;

 //need here only to fix *.lfm parse fail on Lazarus4android...
procedure TAndroidModule6.DataModuleCreate(Sender: TObject);
begin
  Self.BackgroundColor:= colbrBlack;
  Self.OnJNIPrompt:= @DataModuleJNIPrompt;
  Self.OnRotate:= @DataModuleRotate;
  Self.OnCloseQuery:= @DataModuleCloseQuery;
end;

procedure TAndroidModule6.DataModuleJNIPrompt(Sender: TObject);
begin
  Self.Show;
end;

procedure TAndroidModule6.DataModuleRotate(Sender: TObject; rotate: integer; var rstRotate: integer);
begin
  Self.UpdateLayout;
end;

procedure TAndroidModule6.jButton1Click(Sender: TObject);
begin
  if jEditText1.Text <> '' then
    jListView1.Items.Add(jEditText1.Text)
  else
    jListView1.Items.Add('item_'+ IntToStr(Random(100)));
end;

procedure TAndroidModule6.jButton2Click(Sender: TObject);
begin
   jListView1.Items.Delete(StrToInt(jEditText2.Text));
end;

procedure TAndroidModule6.jButton3Click(Sender: TObject);
begin
  jListView1.Items.Clear;
end;

procedure TAndroidModule6.jListView1ClickItem(Sender: TObject; Item: Integer);
begin
  ShowMessage(IntToStr(Item));
end;

end.

 
Title: Re: Android Module Wizard
Post by: Leledumbo on November 17, 2013, 03:50:49 pm
So it will look like a data module, no visual design? The layout must be done through code then, right? No problem actually, it's already a big step. The visual designer could wait :D
Title: Re: Android Module Wizard
Post by: jmpessoa on November 17, 2013, 04:24:19 pm
@Leledumbo: 
Quote
The layout must be done through code then, right?

Yes, too. But basically I am using just the Object Inspector to configure the layout, in this sense no coding!

Thank you!
Title: Re: Android Module Wizard
Post by: exdatis on November 17, 2013, 04:27:06 pm
Thank you very much for your effort.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 17, 2013, 04:34:15 pm
And thanks too @simonsayz's  effort!  O:-)
Title: Re: Android Module Wizard
Post by: engkin on November 17, 2013, 08:24:41 pm
The image you posted for your list view demo looks impressive!. I'm standing in the queue with other eager people that want to try it, patiently.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 17, 2013, 08:36:51 pm

Hi engkin,

Thanks for your interest .... I will need help for the next step: build the entire cycle of application without Eclipse!

Greetings!
Title: Re: Android Module Wizard
Post by: engkin on November 17, 2013, 08:53:16 pm
I'm willing to help, assuming that I'm able to.  :-[
Title: Re: Android Module Wizard
Post by: Leledumbo on November 18, 2013, 04:47:49 pm
Quote
Yes, too. But basically I am using just the Object Inspector to configure the layout, in this sense no coding!
Hmm... does it use relative positioning or absolute or something else?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 18, 2013, 06:01:47 pm
@Leledumbo

Quote
Hmm... does it use relative positioning or absolute or something else?

Yes, relative e something else too! :D

In my posted *.lfm, you can see:

Code: [Select]
object jEditText1: jEditText
    Id = 53166
    Anchor = jTextView2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpTwoThirdOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    ...............................................
  end
  object jButton1: jButton
    Id = 0
    Anchor = jEditText1
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneThirdOfParent
    LayoutParamHeight = lpWrapContent
    ..............................................
  end 

The main concept is "Anchor"  and the possibilities (at the moment...) are:

Code: [Select]
TPositionRelativeToAnchor = ( raAbove,
                                  raBelow,
                                  raToStartOf,
                                  raToEndOf,
                                  raToLeftOf,
                                  raToRightOf,
                                  raAlignBaseline,
                                  raAlignTop,
                                  raAlignBottom,
                                  raAlignStart,
                                  raAlignEnd,
                                  raAlignLeft,
                                  raAlignRight);

  TPositionRelativeToParent = (rpBottom,
                               rpTop,
                               rpLeft,
                               rpRight,
                               rpStart,
                               rpEnd,
                               rpCenterHorizontal,
                               rpCenterInParent,
                               rpCenterVertical
                               {rpTrue});

  TLayoutParams = (lpMatchParent, lpWrapContent, lpHalfOfParent, lpOneQuarterOfParent,
                   lpTwoThirdOfParent ,lpOneThirdOfParent, lpOneEighthOfParent,
                   lpOneFifthOfParent, lpTwoFifthOfParent, lpThreeFifthOfParent, lpFourFifthOfParent,
                   lp16px, lp24px, lp32px, lp40px, lp48px, lp72px, lp96px);


and from *.pas you can see:

Code: [Select]
procedure TAndroidModule6.DataModuleRotate(Sender: TObject; rotate: integer;
  var rstRotate: integer);
begin
  Self.UpdateLayout;   <<<----------------- suporte building in!
end;

Follow the attached a image after device direction change....

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on November 19, 2013, 04:48:56 pm
OK, that looks good. At least no need to worry the controls will be overlapping.
Title: Re: Android Module Wizard
Post by: TurboRascal on November 22, 2013, 03:13:15 pm
This seems great, and I guess a visual design could be added completely bypassing the Form Designer - the way reports are created for example. Clicking on a nonvisual component could open a small designer for placing and drawing controls, even a primitive one would be sufficient help for Android, I guess...
Title: Re: Android Module Wizard
Post by: jmpessoa on December 08, 2013, 09:57:45 pm
Hi All,

I got another step in the layout management, especially the device orietation change challenge.

Yes, the *NEW* jPanel simplifies and actually makes this task very easy and "smart".

Follows code and image just for exemplification....

Achieved that goal I inclose the first part of my work and will try to available the new version of my LazAndroidWizard
with support for  simonsayz's  Controls (including my own extensions..

Now I will focus on writing a more complete readme.txt/tutorial.... I want to complete this task as quickly as possible (03 days?)

Thank to All and special thanks to Simonsayz!


*.dfm

Code: [Select]
object AndroidModule1: TAndroidModule1
  OnCreate = DataModuleCreate
  OldCreateOrder = False
  BackButton = True
  Title = 'jForm'
  BackgroundColor = colbrBlack
  OnRotate = DataModuleRotate
  OnJNIPrompt = DataModuleJNIPrompt
  Height = 424
  HorizontalOffset = 424
  VerticalOffset = 125
  Width = 265
  object jPanel1: jPanel
    Id = 139436
    PosRelativeToAnchor = []
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpOneThirdOfParent
    MarginLeft = 0
    MarginTop = 0
    MarginRight = 0
    MarginBottom = 0
    Visible = True
    BackgroundColor = colbrLightSteelBlue
    left = 64
    top = 8
  end
  object jPanel2: jPanel
    Id = 0
    Anchor = jPanel1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpMatchParent
    MarginLeft = 0
    MarginTop = 0
    MarginRight = 0
    MarginBottom = 0
    Visible = True
    BackgroundColor = colbrWhite
    left = 64
    top = 304
  end
  object jTextView1: jTextView
    Id = 3313746
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    ParentPanel = jPanel1
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrRed
    FontSize = 0
    Text = 'jPanel Demo'
    left = 136
    top = 8
  end
  object jButton1: jButton
    Id = 2882086
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    ParentPanel = jPanel1
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'Show Image Light'
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    left = 136
    top = 72
  end
  object jImageView1: jImageView
    Id = 0
    Anchor = jTextView3
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpMatchParent
    MarginLeft = 0
    MarginTop = 0
    MarginRight = 0
    MarginBottom = 0
    ParentPanel = jPanel2
    ImageIndex = 0
    Images = jImageList1
    Visible = True
    BackgroundColor = colbrDefault
    BackgroundImage = False
    left = 120
    top = 360
  end
  object jImageList1: jImageList
    Images.Strings = (
      'Lazarus_Logo_Light.png'
      'Lazarus_Logo_Dark.png'
    )
    left = 192
    top = 360
  end
  object jButton2: jButton
    Id = 4091625
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    ParentPanel = jPanel1
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'Show Image Dark'
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton2Click
    left = 136
    top = 134
  end
  object jTextView2: jTextView
    Id = 0
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpBottom, rpRight]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    ParentPanel = jPanel1
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrMidnightBlue
    FontSize = 0
    Text = 'Panel 1'
    left = 136
    top = 192
  end
  object jTextView3: jTextView
    Id = 9682626
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpLeft]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    ParentPanel = jPanel2
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrSlateBlue
    FontSize = 0
    Text = 'Lazarus_Logo'
    left = 120
    top = 304
  end
  object jTextView4: jTextView
    Id = 5428635
    Anchor = jTextView3
    PosRelativeToAnchor = [raAlignBaseline, raAlignRight]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    ParentPanel = jPanel2
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrMidnightBlue
    FontSize = 0
    Text = 'Panel 2'
    left = 192
    top = 304
  end
end


*.pas

Code: [Select]
{Hint: save all files to location: C:\adt32\eclipse\workspace\AppDemo2\jni }
unit unit1;
 
{$mode delphi}
 
interface
 
uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls;
 
type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
      jButton1: jButton;
      jButton2: jButton;
      jImageList1: jImageList;
      jImageView1: jImageView;
      jPanel1: jPanel;
      jPanel2: jPanel;
      jTextView1: jTextView;
      jTextView2: jTextView;
      jTextView3: jTextView;
      jTextView4: jTextView;
      procedure DataModuleCreate(Sender: TObject);
      procedure DataModuleJNIPrompt(Sender: TObject);
      procedure DataModuleRotate(Sender: TObject; rotate: integer;
        var rstRotate: integer);
      procedure jButton1Click(Sender: TObject);
      procedure jButton2Click(Sender: TObject);
    private
      {private declarations}
    public
      {public declarations}
  end;
 
var
  AndroidModule1: TAndroidModule1;

implementation
 
{$R *.lfm}
 

{ TAndroidModule1 }

procedure TAndroidModule1.DataModuleCreate(Sender: TObject);
begin
  OnJNIPrompt:= DataModuleJNIPrompt;    {<-- delphi mode...}
  OnRotate:= DataModuleRotate;          {<-- delphi mode...}
end;

procedure TAndroidModule1.DataModuleJNIPrompt(Sender: TObject);
begin
  jTextView3.Text:= jImageView1.ImageName;  //Lazarus_Logo_Light.png
  Self.Show;
end;

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
   jImageView1.ImageIndex:= 0;
   jTextView3.Text:= jImageView1.ImageName;  //Lazarus_Logo_Light.png
end;

procedure TAndroidModule1.jButton2Click(Sender: TObject);
begin
    jImageView1.ImageIndex:= 1;
    jTextView3.Text:= jImageView1.ImageName;  //Lazarus_Logo_Dark.png
end;

{rotate=1 --> device is on  vertical/default position; rotate=2 device is on horizontal position}
procedure TAndroidModule1.DataModuleRotate(Sender: TObject; rotate: integer; var rstRotate: integer);
begin
   if rotate = 2 then   //after rotation device is on horizontal
   begin
      jPanel1.LayoutParamHeight:=lpMatchParent;
      jPanel1.LayoutParamWidth:= lpHalfOfParent;
      jPanel2.PosRelativeToAnchor:= [raToRightOf,raAlignBaseline];
    end
    else {1} //after rotation device is on vertical/default
    begin
      jPanel1.LayoutParamHeight:= lpOneThirdOfParent;
      jPanel1.LayoutParamWidth:= lpMatchParent;
      jPanel2.PosRelativeToAnchor:= [raBelow];
    end;
    Self.UpdateLayout;
end;

end.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 14, 2013, 06:20:29 am
Hi All,

The Android Module Wizard version 0.2

that Introduces Android GUI Components - Based on Simonsayz's controls

is on https://github.com/jmpessoa/lazandroidmodulewizard

The Demos [Eclipse Projects] are here:

    AppDemo1 - ref1. https://www.opendrive.com/files?Ml8zNjMwNTE0N18xVUZ2ag
   
             - A complete remake of Simonsayz's Demo     


    AppDemo2 - ref2. https://www.opendrive.com/files?Ml8zNjMwNTMxN19YTHgxWg
             - Introduce jPanel e jCamara

    :: Please, look for Lazarus project on \jni folder...
   
Yes, Lazarus does RAD for Android!

Yes, the work is just beginning!

Any assistance is very welcome!

Thank to All and special thanks to Simonsayz!

Here is the  complete "readme.txt"
Quote

Lazarus Android Module Wizard
            

"A wizard for create JNI Android loadable module (.so) in Lazarus/Free Pascal using DataModules"


      Author: Jose Marques Pessoa : jmpessoa__hotmail_com

       https://github.com/jmpessoa/lazandroidmodulewizard

            http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html

          Acknowledgements: Eny and Phil for the Project wizard hints...

                 http://forum.lazarus.freepascal.org/index.php/topic,20763.msg120823.html#msg120823

              Felipe for the Android support...

              TrueTom for the Laz4Android Package (laz4android1.1-41139)
                     
      https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6%21149
             
             Simonsayz for the great work on Android [GUI] Controls

                http://forum.lazarus.freepascal.org/index.php/topic,22079.0.html

             Lazarus forum community!


version 0.2 - December 2013 -

   :: NEW! Introduces Android GUI Components - Based on Simonsayz's controls [item IV]
   

   :: revision 0.1 - 09 September - 2013 - Bugs fixs!


version 0.1 - August 2013 -


   [1] Warning: at the moment this code is just a *proof-of-concept*
     

I. INSTALL Laz4Android (https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6%21149)

      warning: the original laz4android1.1-41139 is win32 and just for Android NDK-7c

   1. From lazarus IDE - Install Wizard Packages

      1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk"

     Ref. image: https://www.opendrive.com/files?Ml8zNjMwNDQ3NF83SzhsZg

      1.1.1 From Package Wizard

            - Compile
            - Use -> Install
 
      1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
   
      1.2.1 From Package Wizard

            - Compile
            - Use -> Install


II. GENERIC USE

1. From Eclipse IDE - Create Android Project

  1.1. File -> New -> Android Application Project ...[Next], [Next]...[Finish]!

  1.2. From Package Explore -> src
   
       :Right click your recent created package -> new -> class 
   
       :Enter new class name... (ex. JNIHello)
   
       :Edit class code for wrapper native methods
   
        ex:

   public class JNIHello {

      public native String getString(int flag);
      public native int getSum(int x, int y);

           static {
      try {
               System.loadLibrary("jnihello");  //*              
      } catch(UnsatisfiedLinkError ule) {
          ule.printStackTrace();
      }
           }

        } 

   
  1.3. * warning: System.loadLibrary("...") must match class Name "lowercase"...
       ex. JNIHello -> "jnihello"
       
   
2. From lazarus IDE (laz4android1.1-41139)

   2.1. On "Create a new project" Dialog select: <JNI Android Module>

        ref. Image: https://www.opendrive.com/files?Ml8zNjMwMTY4MF9HMVRHRg

   2.2. From "Android Module Wizard: Configure Paths"

   Ref. Image: https://www.opendrive.com/files?Ml8zNjMwMTk0Nl9hNEtBUw

     -Path to Eclipse Workspace

         ex. C:\adt32\eclipse\workspace
           
     -Path to Ndk Plataforms

         ex. C:\adt32\ndk7\platforms\android-8\arch-arm\usr\lib
 
     -Path to Ndk Toolchain 
       
   ex. C:\adt32\ndk7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.4.3
     
     -Path to  Simonsayz's  code  templates (App.java + Controls.java):   //**
     
   ex. C:\laz4android\components\LazAndroidWizard\java
 
     -Select [Eclipse] Project Name:                                     //**
 
   ex. C:\adt32\eclipse\workspace\AppDemo 


      ** needed only for Android Components Bridges...       

   2.3. OK


   2.4. From "Android Module Wizard: Select Java Source for JNI..."

      -Select the Java wrapper class for native methods....
 
        ex. "JNIHello.java"

   2.5. OK 

      - Pascal JNI Interface was created!    

   2.6. follow the code hint: "save all files to location....." {save all in \jni folder ...}

     
   2.7. Implement the Pascal JNI Interface methods.....

   2.8. From Lazarus_FOR_ANDROID IDE

     Run -> Build         {.so was created! see \libs folders....}

   2.9. Yes! You got it!


III. BUILD and RUN ANDROID APPLICATION

   1.  From Eclipse IDE

        1.1.  double click your recent created project //that is: open project...

   1.1.  right click your recent created project -> Refresh
   
   1.2.  right click your recent created project -> Run as -> Android Application


IV. SPECIAL GUIDE FOR ANDROID BRIDGES COMPONENTS USE   - NEW

   1. From Eclipse IDE:

        1.1. File -> New -> Android Application Project
       
   1.2. [Next]
   1.3. [Next]
   1.4. [Next]
   
   1.5. On "Create Activity" Dialog select: <Blank Activity>   [Next]
             
             ref. Image: https://www.opendrive.com/files?Ml8zNjMwMDUwOF9pZm4xMQ

        1.6. On "Activity Name" Dialog enter: App  [Finish] //"App" name is mandatory!
                 
             ref. Image: https://www.opendrive.com/files?Ml8zNjMwMDE0M19aZ2dkeA
       
          1.7  Right click your recent created project -> Close 

   2. From Lazarus IDE
   
   2.1. Project -> New Project
       
   2.2. On "Create a new project" Dialog select: <JNI Android Module>

        ref. Image: https://www.opendrive.com/files?Ml8zNjMwMTY4MF9HMVRHRg

   2.3. From "Android Module Wizard: Configure Paths"

      -Path to Eclipse Workspace

          ex. C:\adt32\eclipse\workspace
           
           -Path to Ndk Plataforms

                ex. C:\adt32\ndk7\platforms\android-8\arch-arm\usr\lib
 
           -Path to Ndk Toolchain 

               ex. C:\adt32\ndk7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.4.3
     
           -Path to  Simonsayz's  code  templates (App.java + Controls.java): 

               ex. C:\laz4android\components\LazAndroidWizard\java
 
           -Select [Eclipse] Project Name:                                   

               ex. C:\adt32\eclipse\workspace\AppDemo1 

          ref. Image: https://www.opendrive.com/files?Ml8zNjMwMTk0Nl9hNEtBUw

         2.4. From "Android Module Wizard: Select Java Source for JNI..."

      -From left panel/tree Select src-> ...-> "your recent created project"

                -From top panel/View right click "App.java" file

      -On Popup menu select/click <Get Simonsayz's Templates>
           
          ref. Image: https://www.opendrive.com/files?Ml8zNjMwMjI1Ml9kOXNRag

                -Double Click "Control.java" file...
 
          ref. Image: https://www.opendrive.com/files?Ml8zNjMwMjkyM183ZVd2MA

   2.5. OK 

         - Pascal JNI Interface was created!    

   2.6. follow the code hint: "save all files to location....."  { \jni folder }


   2.7. From Component Palete select page <Android Bridges>

         ref. Image: https://www.opendrive.com/files?Ml8zNjMwNDQ3NF83SzhsZg
                           
      -Put e configure some component on DataModule form... etc...

   2.8. From Lazarus IDE

      -Run -> Build
    

        2.9.  From Eclipse IDE

          -Double click recent created project     {Open project ...}

          -Right click your recent created project -> Refresh
             
      -Right click your recent created project -> Run as -> Android Application
       
   
V. Yes! Lazarus/Free Pascal does RAD on Android!


VI. Download Demos [Eclipse Projects]

    AppDemo1 - ref1. https://www.opendrive.com/files?Ml8zNjMwNTE0N18xVUZ2ag
    AppDemo2 - ref2. https://www.opendrive.com/files?Ml8zNjMwNTMxN19YTHgxWg

VII. Ref. Lazarus forum: http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html

     -Help and Hints
     -Bugs
     -Sugestions
     -Colaborations   
     -Critics
     -Roadmap
     -etc..

VIII. The work is just beginning!




Title: Re: Android Module Wizard
Post by: Leledumbo on December 14, 2013, 07:45:25 am
Thank you, jmpessoa. I'm on my way to the github page :D
You should put the demo in the github as well IMO, better in its own folder and let everybody adds their own

Hmm... it seems that Eclipse (workspace) is required to create any project with this. I think it could be removed and we could provide standard Android project structure that only requires ant to build, as simonsayz libraries do.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 14, 2013, 04:17:36 pm

@Leledumbo,

Yes, the Eclipse dependency needs to be removed!

I will try learn about  this part of the problem, I will study @simonsayz solution and @delphifreak solution....

Yes, I put the AppDemos on github now...

Thank you very much for your interest!


Title: Re: Android Module Wizard
Post by: Sergionn on December 14, 2013, 04:59:39 pm
Also thank you, Jmpessoa for your work!!!!!!!!!
Eclipse dependency not the right way, it should be done like in Simon's work.
By the way - maybe someones knows - what happends with Simon, why he does't continue his work?
Title: Re: Android Module Wizard
Post by: Leledumbo on December 14, 2013, 05:15:20 pm
Hmm... I got linker errors due to either .lpk requiring NDK libraries to link with the IDE but it's not stated anywhere in the readme.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 14, 2013, 05:45:01 pm

@Leledumbo:

I put this on readme.txt:

Code: [Select]
  warning: the original laz4android1.1-41139 is win32 and just for Android NDK-7c

but I do not know if I understood your question ...

@Sergionn:

Yes, Simon help is very important, I tried some communication with him but had no success...

Thank you.
   
Title: Re: Android Module Wizard
Post by: Leledumbo on December 14, 2013, 06:22:10 pm
Quote
I put this on readme.txt:

Code: [Select]
  warning: the original laz4android1.1-41139 is win32 and just for Android NDK-7c

but I do not know if I understood your question ...
Upon installing, I got these:
Quote
/usr/bin/ld: cannot find -lGLESv2
/usr/bin/ld: cannot find -lGLESv1_CM
/usr/bin/ld: cannot find -ljnigraphics
/usr/bin/ld: cannot find -llog
I do know they're part of NDK, it's easy to find them. But any of the .lpk doesn't contain path to these libs (-Fl) and the readme contains no instruction for this.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 14, 2013, 06:43:44 pm
@Leledumbo,

1. You is using Windows or Linux?

2. Please check my "Android Module Wizard: Configure Paths"

    ref Image:     https://www.opendrive.com/files?Ml8zNjMwMTk0Nl9hNEtBUw

3. Yes, they're part of NDK,  the interfaces are:

    Laz_And_GLESv1_Canvas_h.pas
    Laz_And_GLESv2_Canvas_h.pas
    And_bitmap_h.pas
    And_log_h.pas

I'm trying to understand your question.

Thank you.
Title: Re: Android Module Wizard
Post by: Leledumbo on December 14, 2013, 06:54:02 pm
Quote
You is using Windows or Linux?
Linux
Quote
Please check my "Android Module Wizard: Configure Paths"
I haven't gone that far, the problem appears when installing the .lpk to the IDE
Title: Re: Android Module Wizard
Post by: jmpessoa on December 14, 2013, 07:31:26 pm
@Leledumbo,

Linux?

I haven't gone that far too...  :D :(  :-[

1. At the moment "lazandroidwizardpack.lpk" has a simple Windows dependency

the '/'  separator! I will fix this! (Edit: Directory Separator was Fix! )

2. The  "tfpandroidbridge_pack.lpk" I don't remember, I will see. (Edit: No problem found!)

What *.lpk  is you trying?

Thanks.

       

Title: Re: Android Module Wizard
Post by: jmpessoa on December 14, 2013, 07:57:19 pm
Hi,

I Add new infos in Readme.txt,

About Package, Components and LCL  and NDK libs(.so) dependency on laz4android1.1-41139 IDE cross compiler...

1. Package creation: just LCLBase is permitted! not "LCL"!
   
   - You will nedd  LCLBase Required Package for register procedure.
   - yes, other No GUI stuff is permitted.

2. Component creation
   
    2.1. If you will use custom icon then you will need two files: the first to compoment(s) code
        and the second for Register procedure code.

        example:

    2.1.1. File 1 - "foo.pas" - component code - here no LCL dependency at all!

Code: [Select]
unit foo;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils;

type

TFoo = class(TComponent)
  private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;


implementation

 
end.
       
  2.1.2. File 2 - "regtfoo.pas" - register code -  here you will need LCLBase for LResources unit

Code: [Select]
        unit regtfoo;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources{ here is the LCLBase dependency!};

Procedure Register;

implementation

Procedure Register;
begin

  {$I tfoo_icon.lrs}  //you custom icon

  RegisterComponents('Android Bridges',[TFoo);

end;

initialization

end.   

3. NDK libs (.so) dependency on laz4android1.1-41139 IDE cross compiler
     

3.1.  You will need two files: the first to NDK *.so lib interface and the second for you component/unit code.

   Example:


   3.1.1. File 1 - "And_log_h.pas" the header interface file
 
Code: [Select]
unit And_log_h;

{$mode delphi}

interface

const libname='liblog.so';

  ANDROID_LOG_UNKNOWN=0;
      ANDROID_LOG_DEFAULT=1;
      ANDROID_LOG_VERBOSE=2;
      ANDROID_LOG_DEBUG=3;
      ANDROID_LOG_INFO=4;
      ANDROID_LOG_WARN=5;
      ANDROID_LOG_ERROR=6;
      ANDROID_LOG_FATAL=7;
      ANDROID_LOG_SILENT=8;

type

  android_LogPriority=integer;

  function __android_log_write(prio:longint; tag,text: pchar):longint; cdecl; external libname name '__android_log_write';

  function LOGI(prio:longint;tag,text:pchar):longint; cdecl; varargs; external libname name '__android_log_print';


implementation

end.

   
      3.1.2. File 2 - "And_log.pas" component/unit code

Code: [Select]
unit And_log;

interface

uses
   And_log_h;  // <-- here is the link to NDK lib

procedure log(msg: pchar);

implementation

procedure log(msg: pchar);
begin
          __android_log_write(ANDROID_LOG_FATAL,'crap',msg);
end;

end.

Thank you.
Title: Re: Android Module Wizard
Post by: Leledumbo on December 15, 2013, 05:03:07 am
Quote
Linux?

I haven't gone that far too...  :D :(  :-[
I don't think this should be locked to certain platform, if it could work on Windows, it should work on any other supported OS.
Quote
1. At the moment "lazandroidwizardpack.lpk" has a simple Windows dependency

the '/'  separator! I will fix this! (Edit: Directory Separator was Fix! )
Simple, isn't it? The cross platform constants are in the System unit ;)
Quote
2. The  "tfpandroidbridge_pack.lpk" I don't remember, I will see. (Edit: No problem found!)

What *.lpk  is you trying?
Both.
lazandroidmodulewizard has implicit dependencies on jnigraphics in androidwizard_intf due to its dependency on Android_jni_bridge via Laz_And_Controls unit. While tfpandroidbridge has dependencies on all of those .so (GLESv2, GLESv1_CM, jnigraphics, log).
Title: Re: Android Module Wizard
Post by: jmpessoa on December 15, 2013, 05:30:21 am
@Leledumbo

Yes,

I have this problem too on windows and laz4android1.1-41139 cross compile... my solution was that I wrote in my post  up ;D 

Code: [Select]
About Package, Components and LCL  and NDK libs(.so) dependency on laz4android1.1-41139 IDE cross compiler...

And with this strategies it was resolved on windows!

But I learned something else ... before installing a package I close my cross compile project and open a "dummy" windows project....

And so things are working... but on linux it seems that the behavior is another ...

 :'(

Thank you
Title: Re: Android Module Wizard
Post by: Leledumbo on December 15, 2013, 06:20:39 am
I'm going to check what laz4android does so that the IDE can link to those .so

EDIT: it doesn't seem to have anything to do with laz4android, so it's purely tfpandroidbridge problem. On Windows, shared library doesn't have to exist upon linking. While on *nix, it's a must. I need to find a workaround for this.
Title: Re: Android Module Wizard
Post by: zariq on December 15, 2013, 04:54:09 pm
Hi.

Copied appdemo1 onto phone, looks nice. Must have taken a lot of work, jni is very laborious. Just a few of minor points.

I couldn't get the back key to work from the main (menu) form.  I had to press the home key, which leaves it paused in the background or kill it from task manager.

Pressing the return key in edittext inserts a line but also hides the keynoard. That should only happen if it's a "done" or "go".

Just incase you forget imageview needs scaletype implementing. FIT_XY distorts the image if the imageview is larger but wrong scale.

Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 15, 2013, 04:56:56 pm
@Leledumbo,
 
Yes, After many experimentations, I  found a workaround for Windows just as posted up: ;D

Quote
About Package, Components and LCL  and NDK libs(.so) dependency on laz4android1.1-41139 IDE cross compiler...

Thank you.

Title: Re: Android Module Wizard
Post by: jmpessoa on December 15, 2013, 05:12:07 pm
@zariq,

Thank you for the experimentation...

Yes, and our work is just beginning ... I am learning
yet!  surely every collaboration is welcome! JNI is hard and our task is build a RAD environment for android too, Lazarus is about it!

About:
Quote
I couldn't get the back key to work from the main (menu) form.

I will try a solution.

Best regards.



Title: Re: Android Module Wizard
Post by: jmpessoa on December 16, 2013, 11:41:48 pm
Hi All,

Yes, Ant support almost ready!

I got:

1. Compile/Build ---> I got the Apk!
2. Install in Emulator
3. Uninstall from Emulator

But when I run App from Emulator I got:
Quote
E/AndroidRuntime(  913):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(  913):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  913): Caused by: java.lang.NoClassDefFoundError: Controls

E/AndroidRuntime(  913):        at java.lang.Runtime.nativeLoad(Native Method)
E/AndroidRuntime(  913):        at java.lang.Runtime.loadLibrary(Runtime.java:369)
E/AndroidRuntime(  913):        at java.lang.System.loadLibrary(System.java:535)
E/AndroidRuntime(  913):        at lazarus.org.appantdemo1.Controls.<clinit>(Controls.java:3948)
E/AndroidRuntime(  913):        ... 15 more
E/AndroidRuntime(  913): Caused by: java.lang.ClassNotFoundException: Didn't find class "Controls" on path: /data/app/lazarus.org.appantdemo1-1.apk

E/AndroidRuntime(  913):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
E/AndroidRuntime(  913):        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(  913):        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(  913):        ... 19 more

My build.xml is simply:
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
  <project name="AppAntDemo1" default="help">
  <property name="sdk.dir" location = "C:\adt32\sdk"/>
  <property name="target"  value="android-17"/>
  <property file="ant.properties"/>
  <fail message="sdk.dir is missing." unless="sdk.dir"/>
  <import file="${sdk.dir}\tools\ant\build.xml"/>
</project>

Something was forgotten to bind  my native "libcontrols.so" on Apk?

Thank You.

Edit: I found this:
Quote
  It turns out that this was a bug in the Android SDK. The release notes of r18 say:

  "Fixed Ant issues where some jar libraries in the libs/ folder are not picked up in some cases."

  Since updating from r17 to r19 fixed the problem for me, this was very likely the cause of the problem.

Ref. http://stackoverflow.com/questions/9944698/why-is-the-android-support-library-not-added-to-my-apk

I will update my SDK r17 for r19 too, and try again!

Edit2: While I wait for my SDK update, I ran:

aapt.exe list AppAntDemo1-debug.apk, and for my surprise:
Quote
res/layout/activity_app.xml
AndroidManifest.xml
resources.arsc
res/drawable-hdpi/ic_launcher.png
res/drawable-ldpi/ic_launcher.png
res/drawable-mdpi/ic_launcher.png
res/drawable-xhdpi/ic_launcher.png
res/drawable-xxhdpi/ic_launcher.png
classes.dex
lib/armeabi/libcontrols.so    <<----------- yes !
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA

My libcontrols.ao is there! Then, what is incorrect  in my apk?
Title: Re: Android Module Wizard
Post by: zariq on December 18, 2013, 02:36:12 am
 Didn't find class "Controls"

In the version I downloaded you had controls with a small c.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 18, 2013, 04:21:05 am
@Zarik,

thank you for replay.

I have a file  "Controls.java" and a class "Controls":
Code: [Select]
//------------------------------------------------------------------------------
//Javas/Pascal Interface Class
//------------------------------------------------------------------------------
//!!!! classcontrols 
//
public  class Controls {
//
public   Activity       activity;            // Activity
public   RelativeLayout appLayout;           // Base Layout
public   int            screenStyle = 0;     // Screen Style [Dev:0 , Portrait: 1, Landscape : 2]

// Jave -> Pascal Function ( Pascal Side = Event )
public  native int  pAppOnScreenStyle();
public  native void pAppOnCreate     (Context context,RelativeLayout layout);
public  native void pAppOnNewIntent  ();
public  native void pAppOnDestroy    ();
public  native void pAppOnPause      ();
public  native void pAppOnRestart    ();
public  native void pAppOnResume     ();
public  native void pAppOnActive     ();
public  native void pAppOnStop       ();
public  native void pAppOnBackPressed();
public  native int  pAppOnRotate     (int rotate);
public  native void pAppOnConfigurationChanged();
public  native void pAppOnActivityResult(int requestCode, int resultCode, Intent data);
//
public  native void pOnClick     (int pasobj, int value);
public  native void pOnChange    (int pasobj, int EventType);
public  native void pOnEnter     (int pasobj);
public  native void pOnTimer     (int pasobj);
//
public  native void pOnDraw      (int pasobj, Canvas canvas);
public  native void pOnTouch     (int pasobj, int act, int cnt,float x1, float y1,float x2, float y2);
public  native void pOnGLRenderer(int pasobj, int EventType, int w, int h);
//
public  native void pOnClose     (int actform);
//
public  native int  pOnWebViewStatus (int pasobj, int EventType, String url);
public  native void pOnAsyncEvent    (int pasobj, int EventType, int progress);

// Load Pascal Library
static {
    Log.i("JNI_Java", "1.load libcontrols.so");
    System.loadLibrary("controls");
    Log.i("JNI_Java", "2.load libcontrols.so");
   
}

Yes, there is a small "control" in System.loadLibrary("controls").....

And more, in my /bin/classes I got the compiled  "Controls.class"!  %)
Title: Re: Android Module Wizard
Post by: jmpessoa on December 19, 2013, 07:49:32 pm
Yes,  after a complete cleanup in my Android SDK, the problem was solved! 8-)

The support for Ant project is on the way!

Thanks to All.
Title: Re: Android Module Wizard
Post by: Leledumbo on December 20, 2013, 07:31:20 am
I'm still struggling to make the package installable on Linux. It's kinda weird actually since, for example, the And_Bitmap_h functions called links to libjnigraphics.so which is part of the TARGET (Android), the HOST (Linux) shouldn't need it. Even if it should, which libjnigraphics.so should the IDE link to? x86? arm? Neither is right, since the .so is not meant for the HOST.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 22, 2013, 08:12:44 am
Hi All,

Android Module Wizard Ver. 0.3 -  Introduces Support to Ant Project!

Now you can manage the entire cycle of application development just
using Lazarus  and native tools:  jdk, ant, sdk and ndk.

You can get here:

         http://wwww.github.com/jmpessoa

For a complete description, please, read the updated "readme.txt"

Attached below the new entry form for project and paths configuration...

Thank to all!

Title: Re: Android Module Wizard
Post by: Sergionn on December 22, 2013, 08:36:47 am
Jmpessoa, yor are good for strugging for pascal's future by doing this. Thank you!
But give you you little advice:
1) Simplify all STEPS to do to archive the result, it should be like this:
 a) install packadge
 b) load project
 c) build it
 - thats it, until this it will be more easy to make android apps in andoid studio or eclipse or whatever
 and even to study java not such commplicated quest compared by following all instructions in readme file of your project........
 and please remove eclipse projects and any dependency about it for simpify

Title: Re: Android Module Wizard
Post by: jmpessoa on December 22, 2013, 03:42:21 pm
@Sergionn, thaks for your advice:

I will, split "readme.txt": one for Eclipse users and other for Ant users.... I hope  so things will be less complicated... the fact is that there is still a java background in development (Simon's "Control.java" + "App.java") and so support the eclipse help much ...

Thank you!




 
Title: Re: Android Module Wizard
Post by: jmpessoa on December 22, 2013, 07:55:48 pm
Ok,

Thanks to @Sergionn,

Now there are two fast tutorials: one for Ant users and other for Eclipse users.

From " fast_tutorial_ant_users.txt":                    ref. http://www.github.com/jmpessoa
Quote

**Tutorial: Lazarus Android Module Wizard for "Ant" users **
            
"A wizard for create JNI Android loadable module (.so) in Lazarus/Free Pascal using DataModules"


      Author: Jose Marques Pessoa : jmpessoa__hotmail_com
     
      Please, for complete reference read "readme.txt"


I. INSTALL Laz4Android (https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6%21149)
   
      warning: the original laz4android1.1-41139 is win32 and just for Android NDK-7c

      HINT: To install/reinstall a package open a "dummy" windows project.... you always MUST close the cross compile project!
 
   1. From Laz4Android IDE (laz4android1.1-41139)  - Install Wizard Packages

      1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk"

     Ref. image: https://www.opendrive.com/files?Ml8zNjMwNDQ3NF83SzhsZg

      1.1.1 From Package Wizard

            - Compile
            - Use -> Install
 
      1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
   
      1.2.1 From Package Wizard

            - Compile
            - Use -> Install



II. [GUI Support] Android Components Bridges - NEW! Simon's Controls remake with many extensions!
       
       
  1. From Lazarus IDE
   
   1.1. Project -> New Project
       
   1.2. On "Create a new project" Dialog select: <JNI Android Module>

        ref. Image: https://www.opendrive.com/files?Ml8zNjMwMTY4MF9HMVRHRg
       

        1.3. From "Android Module Wizard: Configure Paths"

             ref. Image: https://www.opendrive.com/files?Ml8zNjg3MDU0MV9nTXZsdA
                         

            -Path to Ndk Plataforms

             ex. C:\adt32\ndk7\platforms\android-8\arch-arm\usr\lib
 

            -Path to Ndk Toolchain 
       
             ex. C:\adt32\ndk7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.4.3
     
            -Path to  Simonsayz's  code  templates (App.java + Controls.java): 
     
             ex. C:\laz4android\components\LazAndroidWizard\java

            -Path to Workspace

             ex. C:\adt32\Ant\workspace


            -Ant Project Name:       Ant Preface Package Name:                                             
 
             ex. AppAntDemo1            ex. org.jmpessoa  -warning: then final package name will be:            "org.jmpessoa.appantdemo1"
                                   
            -Select other Options [Instructions; FPU; Project; GUI Controls; Target Api]

        1.4. OK!
                         
        1.5. From "Android Module Wizard: Select Java Source for JNI..."

      -From left panel/tree Select "your recent created project" -> src

                -From top panel/View right click "App.java" file

      -On Popup menu select/click <Get Simonsayz's Templates>
           
          ref. Image: https://www.opendrive.com/files?Ml8zNjMwMjI1Ml9kOXNRag

                -Double Click "Control.java" file...
 
          ref. Image: https://www.opendrive.com/files?Ml8zNjMwMjkyM183ZVd2MA

   1.6. OK 

         - Pascal JNI Interface was created!    

   1.7. follow the hint on code: "save all files to location....."  { \jni folder }

   1.8. From Component Palette select page <Android Bridges>
       
            ref. Image: https://www.opendrive.com/files?Ml8zNjMwNDQ3NF83SzhsZg
                           
      -Put e configure some component on DataModule form... etc...

   1.9. From Lazarus IDE

      -Run -> Build

        2.0. Read the "readme.txt" in your project folder to buidl Android Application [Apk]
                           
III. Yes! Lazarus/Free Pascal does RAD on Android!

IV. Download Demos

    [Eclipse Projects]

      AppDemo1 - ref1. https://www.opendrive.com/files?Ml8zNjMwNTE0N18xVUZ2ag 
      AppDemo2 - ref2. https://www.opendrive.com/files?Ml8zNjMwNTMxN19YTHgxWg

    [Ant Projects]
     
      AppAntDemo1 - ref3. https://www.opendrive.com/files?Ml8zNjk2NDU4NF94ck5Fdw

Thank you!

    _____jmpessoa_hotmail_com_____


Thank to All.




Title: Re: Android Module Wizard
Post by: jmpessoa on December 28, 2013, 11:00:54 pm
Hi,

I have updated "Lazarus Android Module Wizard" : ver. 0.3 - rev. 0.1 

   ref. http://www.github.com/jmpessoa

some news:

- Introduces Support for multi build modes [ArmV6, ArmV7a, x86];

-Introduce Support for new TrueTom Laz4Android :: win32/NDK-9/{ARM and x86 !}
   
   ref. https://sourceforge.net/projects/laz4android/files/?source=navbar

- Introduce Support for NoGUI Ant Project;

-some improvements in the files:
               "readme.txt",
               "fast_tutorial_eclipse_users.txt" and
                "fast_tutorial_ant_users.txt"

-New No GUI Demo Projects.

Follows attached the new (simpler) GUI interface for Path/Project Configurations.

Thanks for all !
Happy 2014 !!
Title: Re: Android Module Wizard
Post by: Sergionn on December 29, 2013, 09:06:05 am
Thanks again for your work!
And happy new 2014 year too!
Also can you share your investigations in using freetype2 lib on android?
http://forum.lazarus.freepascal.org/index.php?topic=21923.0
Title: Re: Android Module Wizard
Post by: Leledumbo on December 29, 2013, 05:21:56 pm
I've managed to make the package linked on linux, using some dirty hacks:
Required changes:
Code: [Select]
// in Laz_And_GLESv1_Canvas_h
libname = {$ifdef android}'libGLESv1_CM.so'{$else}'libGL.so'{$endif};
// in Laz_And_GLESv2_Canvas_h
libname = {$ifdef android}'libGLESv2.so'{$else}'libGL.so'{$endif};
The only missing OpenGL function is glFustrumf, which I add in the dummy libjnigraphics. The idea of this is just to make the package installable in the IDE, applications will still use the android version of the libraries.

UPDATE: Ant demo project works beautifully on my MI2S :)
Just a suggestion: no need to rar any of the demo projects, let them as is for easy update. Compressing will only make update tracking difficult.

UPDATE #2: Eclipse demo projects easily converted to Ant project, just need to copy build.xml in the AppAntDemo1. I found some bugs with these demos, such as not being able to exit app by pressing back, but that's just a little bug which I think could easily be fixed.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 29, 2013, 05:40:24 pm
@Leledumbo,

Congratulation!

I think this is very important because this approach can be applied in others portings (mac ?)...

Thank You!

EDITED 1:

  I can apply like:
 
Code: [Select]
  libname = {$ifdef android}'libGLESv1_CM.so'
                 {$else ifdef linux}'libGL.so'{$endif};
   this will work ?

EDITED 2: the changes was applied!
Quote
     New! Support for Linux! Thanks to Leledumbo!
Quote
     by Leledumbo for Linux users:
              1. Build all libraries in the  ../LazAndroidWizard/linux/dummylibs
              2. Put it somewhere ldconfig can find (or just run ldconfig with their directories as arguments)

                "The idea of this is just to make the package installable in the [Lazarus for Linux] IDE,
                  applications will still use the android version of the libraries."
 
              ref. http://forum.lazarus.freepascal.org/index.php/topic,21919.msg137216/topicseen.html


EDITED 3: well,  I  applied something more conservative:
Code: [Select]
  libname = {$ifdef linux}'libGL.so'{$else}'libGLESv1_CM.so'

ok?
Title: Re: Android Module Wizard
Post by: jmpessoa on December 29, 2013, 11:13:59 pm
Hi all,

I make a important fix to AndroidManifest produce... in "uformandroidproject.pas"
 
This bug was  introduced after some minor fix... I'm sorry!

ref.  http://www.github.com/jmpessoa

Thank to all!



Title: Re: Android Module Wizard
Post by: Leledumbo on December 30, 2013, 04:09:20 am
Quote
libname = {$ifdef linux}'libGL.so'{$else}'libGLESv1_CM.so'
This should be OK, since it's really intended for Linux system only. However, if you want to support other OSes, this name must be adjusted for each.

Have you tested it yourself anyway?
Title: Re: Android Module Wizard
Post by: jmpessoa on December 30, 2013, 03:51:31 pm
@Leledumbo,

Quote
Have you tested it yourself anyway?

Yes, I do. That is Ok for Windows...  yes, a more flexible solution is need (what about mac?).  But, I  know the  "{$ifdef}" syntax  very very little...   :D 
Title: Re: Android Module Wizard
Post by: zariq on December 30, 2013, 04:45:49 pm
From the latest downloads, clicking ok after choosing jni android module from the new project dialog results in a Class "TGroupBox" not found messagebox.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 30, 2013, 05:06:27 pm

Thank you Zarik!

Sorry, this bug was  introduced after some minor change... Fixed!


Title: Re: Android Module Wizard
Post by: Leledumbo on December 30, 2013, 06:08:39 pm
Quote
Yes, I do. That is Ok for Windows...
I mean, on Linux. Maybe I miss something in my explanation, I need to make sure that it works on someone else's machine, not just mine.
Title: Re: Android Module Wizard
Post by: zariq on December 30, 2013, 08:06:30 pm

Sorry, this bug was  introduced after some minor change... Fixed!


Thank you.
Title: Re: Android Module Wizard
Post by: zariq on December 30, 2013, 10:48:23 pm
I've managed to create a project and it's running on a device. I can put buttons and other stuff and works ok. In the onclick for a button I did a showmessage and assigned some text to a textview, unfortunately both actions result in a crash. The error is:

12-30 21:41:00.280: E/dalvikvm(4791): JNI ERROR (app bug): accessed stale local reference 0x1ea00025 (index 9 in a table of size 7)
12-30 21:41:00.280: E/dalvikvm(4791): VM aborting
12-30 21:41:00.280: A/libc(4791): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 4791 (com.example.app).

Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 30, 2013, 11:08:15 pm
Hi zarik,

Please, put you "unit1.pas" and "*.lfm" here.... I wil try help.

Thank you.
Title: Re: Android Module Wizard
Post by: zariq on December 30, 2013, 11:22:52 pm
Code: [Select]
{Hint: save all files to location: C:\Users\mustafa\workspace\App\jni }
unit unit1;
 
{$mode delphi}
 
interface
 
uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls;
 
type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
      jButton1: jButton;
      jButton2: jButton;
      jTextView1: jTextView;
      procedure DataModuleCreate(Sender: TObject);
      procedure DataModuleJNIPrompt(Sender: TObject);
      procedure DataModuleRotate(Sender: TObject; rotate: integer;
        var rstRotate: integer);
      procedure jButton1Click(Sender: TObject);
    private
      {private declarations}
    public
      {public declarations}
  end;
 
var
  AndroidModule1: TAndroidModule1;

implementation
 
{$R *.lfm}

{ TAndroidModule1 }

procedure TAndroidModule1.DataModuleCreate(Sender: TObject);
begin        //jus to fix *.lfm parse fail on Laz4Android cross compile...
    Self.OnJNIPrompt:= DataModuleJNIPrompt;
end;

procedure TAndroidModule1.DataModuleJNIPrompt(Sender: TObject);
begin
    Self.Show;
end;

procedure TAndroidModule1.DataModuleRotate(Sender: TObject; rotate: integer;
  var rstRotate: integer);
begin
   Self.UpdateLayout;
end;

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
   ShowMessage('message');
   jTextView1.Text:='text';
end;

end.


I just checked those two statements in button1click, but probably would be same for anything jni.

thanks for looking.
Code: [Select]
object AndroidModule1: TAndroidModule1
  OnCreate = DataModuleCreate
  OldCreateOrder = False
  BackButton = True
  Title = 'jForm'
  BackgroundColor = colbrBlack
  OnRotate = DataModuleRotate
  OnJNIPrompt = DataModuleJNIPrompt
  Height = 343
  HorizontalOffset = 292
  VerticalOffset = 164
  Width = 313
  object jButton1: jButton
    Id = 2238642
    PosRelativeToAnchor = [raAlignLeft]
    PosRelativeToParent = []
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'button1'
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    left = 100
    top = 61
  end
  object jButton2: jButton
    Id = 0
    Anchor = jButton1
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    BackgroundColor = colbrDefault
    Text = 'button2'
    FontColor = colbrDefault
    FontSize = 0
    left = 123
    top = 221
  end
  object jTextView1: jTextView
    Id = 0
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Alignment = taLeft
    Visible = True
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrSilver
    FontSize = 0
    Text = 'jTextView'
    left = 78
    top = 299
  end
end
Title: Re: Android Module Wizard
Post by: jmpessoa on December 31, 2013, 12:16:15 am
@zariq,  try  this change:

Old:

Code: [Select]
object jButton1: jButton
    Id = 2238642
    PosRelativeToAnchor = [raAlignLeft]     <<<-----------

New:

Code: [Select]
object jButton1: jButton
    Id = 2238642
    PosRelativeToAnchor = []     <<<----------- 

That is,  jButton1 do not have a anchor.... only parent.

EDIT 1: Yes, I got:

"
12-30 23:53:47.100: E/dalvikvm(3693): JNI ERROR (app bug): accessed stale local reference 0xbb100025 (index 9 in a table of size 7)
12-30 23:53:47.100: W/dalvikvm(3693): JNI WARNING: jclass is an invalid local reference (0xbb100025)
12-30 23:53:47.110: W/dalvikvm(3693):              in Lcom/example/appdemotrybug/Controls;.pOnClick:(II)V (GetMethodID)

"

I'm trying to see what happened .... please, wait.



EDIT 2:

Yes, just some SDK/NDK/Laz4Android incompatibility!

Please, change AndroidManifest.xml

you have something like this:
Code: [Select]
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>

Change simply to:
Code: [Select]
<uses-sdk android:minSdkVersion="10"/>


Please, make this change in your template too:

  ...\LazAndroidWizard\java\AndroidManifest.txt


Thank you very much! Fixed on GitHub.
Title: Re: Android Module Wizard
Post by: zariq on December 31, 2013, 02:57:24 am
My lfm got  got corrupted so deleted project. Having trouble getting it to run this time round. Had different names for application and activity wouldn't work, renaming  application to same as activity solved it, but because of conflicts due to renaming have to create it again. Will let you know when I get it going.

By the way should I download the new version or try it with the current one.

thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 31, 2013, 03:09:30 am
@zariq,

Ok.

What project model you is trying? Ant or Eclipse?

Thank you.
Title: Re: Android Module Wizard
Post by: zariq on December 31, 2013, 03:11:20 am
Eclipse.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 31, 2013, 03:21:42 am
Ok.

When you are creating your app the Project name can be any.... only the MainActivity needs to be nomead "App".

Thank you.

Title: Re: Android Module Wizard
Post by: zariq on December 31, 2013, 03:24:21 am
Making the change in manifest works for showmessage. Thank you very much.
Title: Re: Android Module Wizard
Post by: zariq on December 31, 2013, 03:31:07 am
Ok, it might have been paths or something.
Title: Re: Android Module Wizard
Post by: jmpessoa on January 02, 2014, 06:53:09 am
Hi,

@zariq,

The problem is in using API > 13 (ex. android:minSdkVersion = 14),  I think that is related to:

http://android-developers.blogspot.cz/2011/11/jni-local-reference-changes-in-ics.html

I'm trying to find a solution!

Thank you!

EDIT: I update GitHub for a more conservative approach: the max for "android:minSdkVersion" on AndroidManifest.xml now is "13"...

Meanwhile, I am seeking for a "true" solution......

EDIT#2: Good News! the bug was solved! more details later ....
Title: Re: Android Module Wizard
Post by: Leledumbo on January 26, 2014, 12:34:55 pm
Hi, jmpessoa. Could you name the wizard form variables (buttons, checkgroups, radios, etc) meaningfully? I would like to change the forms to comply with LCL autosize/layout (http://wiki.lazarus.freepascal.org/Autosize_/_Layout). The forms may look good on Windows, but on other platforms, they're messy.

Also some things for improvement:
Title: Re: Android Module Wizard
Post by: jmpessoa on January 26, 2014, 03:05:11 pm
Hi Leledumbo,

Thanks for your suggestions ...

I'll see if I can make these changes ... in fact I'm still working (a lot!) to overcome the BUG when API > 13.   

This is related here:
http://android-developers.blogspot.cz/2011/11/jni-local-reference-changes-in-ics.html

I needed to re-engineer all the code ... but I think it is now almost done.

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on February 05, 2014, 03:35:28 pm
The back on last (main) formseems to be buggy. The application does exit, but actually it crashes. I can only get these two backtrace lines:
Code: [Select]
I/DEBUG   (  182):     #00  pc 000ad874  /data/data/com.marsoft.piutangman/lib/libcontrols.so (LAZ_AND_CONTROLS_$$_JAVA_EVENT_PAPPONBACKPRESSED$PJNIENV$POINTER+72)
I/DEBUG   (  182):     #01  pc 00023b6c  /data/data/com.marsoft.piutangman/lib/libcontrols.so (P$CONTROLS_$$_PAPPONBACKPRESSED$PJNIENV$POINTER+40)
Looking at the code:
Code: [Select]
AForm := App.Forms.Stack[App.Forms.Index-1].Form;I'm curious with App.Forms.Index, so I add:
Code: [Select]
if App.Forms.Index <= 0 then App.Forms.Index := 1;before that line, and the app doesn't crash but it can't exit as well. So I guess the value is either 0 or less. That makes App.Forms.Index at least -1, while App.Forms.Stack index starts from 0, that's the point where the crash occurs.

I've tried remote debugging but it doesn't seem to work well. GDB says libcontrols.so is missing debugging information, I've tried both stabs and dwarf, neither works.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 05, 2014, 03:45:29 pm
@ Leledumbo,

You are correct .... I also found this problem (and others ...), please wait, I'll try to provide a more stable version later this week with support for api > 13 .....

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on February 09, 2014, 01:00:19 am
   
    Hi All,

     I updated Android Module Wizard.

     version 0.4:: NEW! Add Support for Android API > 13.
         
      A lot of code lines was fix/changed/Added!

      Fix BackButton issue. Now all Forms close correctly.

     Please, see "readme.txt"  and "AppDemo1"  for others changes.    

     ref:  http://github.com/jmpessoa/lazandroidmodulewizard

     @Leledumbo: Now I will try your suggestions...

     Thanks to everyone!


Title: Re: Android Module Wizard
Post by: Leledumbo on February 09, 2014, 03:36:36 am
Git.Pull();

Do you have any tutorial to use the And_jni(_bridge?) to create wrapper for arbitrary Android API? I need to access sqlite, my app would be highly database driven.

EDIT: Found a bug in the Ant demo App.java on line 5, the line should be commented.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 09, 2014, 03:15:46 pm
@ Leledumbo,

    Ok, I will write a "How To".

About:
Quote
Found a bug in the Ant demo App.java on line 5, the line should be commented.

Please, which is the "text" of that line?

Thank you!

EDIT: Ok. A carriage return appeared out of nowhere in my commented line! Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on February 09, 2014, 03:52:18 pm
Quote
Please, which is the "text" of that line?
[and Lazarus by jmpessoa@hotmail.com - december 2013] <- it's not commented

I found another bug, the Ant demo is enough as a test app. Open the app first, then exit by pressing back button. Then try to open the app again. You'll get blank form instead. Another bug in GetPathToJNIFolder, it will return relative path because the first slash (root) will be trimmed as well. I change the routine body to:
Code: [Select]
  i := Pos('src',fullPath);
  if i > 2 then begin
    Result := Copy(fullPath,1,i - 2); // we don't need the trailing slash
  end else
    raise Exception.Create('src folder not found');
because that's what the routine is looking for from my analysis.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 09, 2014, 04:21:14 pm

@Leledumbo,

Please, put the fixed GetPathToJNIFolder here.... I will fix my code for linux Compatibility. Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on February 09, 2014, 04:58:20 pm
The code is above, it's full body of the method.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 09, 2014, 08:16:17 pm
@Leledumbo,

Quote
Open the app first, then exit by pressing back button. Then try to open the app again. You'll get blank form instead

Please, try this in ["Controls.java", line 4468] for all GUI Apps Demos....

Code: [Select]
       public  void appFinish () {
            activity.finish();
           System.exit(0);   // << ----------- Fix Here!
       }

Thank you.
Title: Re: Android Module Wizard
Post by: Leledumbo on February 15, 2014, 12:13:16 pm
Quote
Please, try this in ["Controls.java", line 4468] for all GUI Apps Demos....
OK, that works. Thanks.

Suggestion: Open tfpandroidbridge_pack.lpk->Package Options->Usage->Add paths to dependent packages/projects->Library, then add linux/dummylibs. This will make installation easier on Linux but shouldn't hurt on Windows (but please test, I don't have windows). Anyway, since these libraries are not meant to be used in actual program, I think it's OK to provide a precompiled version of them in the same directory. Or otherwise, provide additional instruction in the readme / fast tutorial to compile these libs before installing the .lpk.

Another question: how can I create a list view with custom content? I want to create something like:
Code: [Select]
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
...
With the ability to add/remove the row anytime.

Last but not least: your demo .apk could run on at least 2.2, while the one I built myself requires at least 4.0. Setting minsdkversion to 10 doesn't seem to work.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 15, 2014, 05:47:58 pm
@Leledumbo,

I'm still here: :D

Quote
I need to access sqlite, my app would be highly database driven.

Yes, the support to Sqlite is almost ready! I think I can still provide it this weekend. And then I will use it to write a "how to"...

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on February 16, 2014, 07:47:46 pm
Hi,

   I have made available a new update to Android Module Wizard.
 
   ref:  http://github.com/jmpessoa/lazandroidmodulewizard

   New!

    Added [Partial] Support to SQLite: 

    .New components: jSqliteDataAccess, jSqliteCursor.

   .Supported FIELD_TYPE at the moment::  INTEGER, STRING, FLOAT     

   .New Eclipse project demo:  AppSqliteDemo1

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on February 17, 2014, 06:05:40 pm
Alright, that's a nice start. I think that's enough for my requirement.
Anyway, have you consulted with the developers about .lfm parsing problem? I think it's appropriate to discuss in FPC mailing list, since {$R support comes from the compiler. As an experiment, you might want to test .lrs resources to see whether the problem also appears there.
If you're OK, please give me write access so I can push my local commits (github account name is the same as here: leledumbo).
I'm still waiting for the custom row on listview ;)
Title: Re: Android Module Wizard
Post by: jmpessoa on February 18, 2014, 11:39:52 pm
@Leledumbo,

Quote
If you're OK, please give me write access so I can push my local commits...

Yes, OK!  you have write access!

Thank you!

EDIT:  Update!!  Image/BLOB Support to SQLite is ready!!!
Title: Re: Android Module Wizard
Post by: jmpessoa on February 23, 2014, 05:34:00 am
@Leledumbo,

Code: [Select]
  I want to create something like:

Code: [Select]
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
...

Quote
   With the ability to add/remove the row anytime.

Ok.  Please, see the picture [attachment] ....

What about?
Title: Re: Android Module Wizard
Post by: Leledumbo on February 23, 2014, 05:44:26 am
Nice! I hope it's not a component by itself, creating the custom row by code is OK for me, as long as I can mix widgets freely.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 23, 2014, 05:59:23 am
Well, as my first attempt I created some new properties to component jListView: hasWigets {CheckBox or RadioButton or Button...} and too  hasImage....

But, that is just a first attempt.... maybe I can create something more flexible like
a property/component "jCustomRow".... 

I will try!

Thank you.
Title: Re: Android Module Wizard
Post by: Leledumbo on February 23, 2014, 11:04:21 am
Quote
But, that is just a first attempt.... maybe I can create something more flexible like
a property/component "jCustomRow".... 
One approach:
jListView can have a property called CustomRow of type "class of jCustomRow". The user may extend the class with other widgets and assign required callbacks.

Another approach:
jListView can have a property called CustomRow, containing a list of widget. I have no idea whether object inspector already supports such a mixed values, so this idea might be less visible than above approach.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 26, 2014, 01:21:08 am
@Leledumbo

Please, clarify his [listview] row requirement. As it should hypothetically be shown? if possible, use real information...

Thank you!

Title: Re: Android Module Wizard
Post by: Leledumbo on February 26, 2014, 06:01:45 am
I want to build a row containing name and checkbox (as a sign that this row is included in the selections) and a textview (for inputting value). I'm creating an application to manage debts and claims, this list will contain the people involved in an event that introduces the debts and claims.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 27, 2014, 02:05:30 am
Ok,

Now we can get something like shown in picture [Attachment], where the rows can be individually modified: image, text, text color, font size, widget [check or radio or button or textview] etc.... and two events can be  handled: list_item click an widget click.

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on February 27, 2014, 09:51:29 am
Thanks, has it been pushed to github?
Title: Re: Android Module Wizard
Post by: jmpessoa on March 01, 2014, 11:08:23 pm
Hi,

I have pushed update version to github!

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Now, we can get something like shown in picture [Attachment].

Thank you!

Title: Re: Android Module Wizard
Post by: Leledumbo on March 02, 2014, 05:09:48 am
Git.Pull();

thanks
Title: Re: Android Module Wizard
Post by: Leledumbo on March 02, 2014, 05:54:02 pm
Could you please try this:
Title: Re: Android Module Wizard
Post by: jmpessoa on March 02, 2014, 06:41:29 pm
I got correct! See my picture [Attachment]. 

Well, I am using just emulator. I will continue testing!

Thank you.

Edit 1: OK, I got this error:

"E/AndroidRuntime(1100):
java.lang.ClassCastException:
android.widget.ImageView cannot be cast to android.widget.CheckBox"...

Just when image is clicked! I will fix this just now!  [BUG FIX !!]

Edit 2: I Will fix/synchronize java side items list and pascal side items list for Add, Clear, Delete... etc... [FIX !!]


Edit 3:  I can modify the

OnClickItem signature: (Sender: TObject; Item: Integer);

To: (Sender: TObject; Item: Integer; itemText: string);

And

OnClickWidgetItem signature: (Sender: TObject; Item: integer; checked: boolean);

To:
OnClickWidgetItem(Sender: TObject; Item: integer; itemText: string; checked: boolean);

What about?

EDIT 4: [FIX EDIT_1 and EDIT_2].
            . Added New Method GetText(index: integer) to jListView.
            .updated AppDemo1...
            . GITHUB was updated!
           
Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on March 21, 2014, 09:37:24 am
Hi, dear android developers.

Project is very good and i'm interesting it. I'm waiting to implement TINIFile or TRegistry classes.

Thanks, good works.
Title: Re: Android Module Wizard
Post by: Leledumbo on March 21, 2014, 10:42:33 am
Quote
Project is very good and i'm interesting it. I'm waiting to implement TINIFile or TRegistry classes.
Not related to this project, those classes should work provided you give the correct android permissions.
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on March 21, 2014, 11:06:09 am
Thank Leledumbo.

I solved my code mistake.

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  INIFile: TINIFile;
  Val: string;
begin

  INIFile := TINIFile.Create('/sdcard/data.ini');
  //INIFile.WriteString('100', '101', 'trial');

  Val := INIFile.ReadString('100', '101', 'error');
  jEditText1.Text := Val;
end;
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on March 21, 2014, 11:56:25 am
I have another question:

Have you got a work of Menu object? I need this object for my project.
Title: Re: Android Module Wizard
Post by: jmpessoa on March 23, 2014, 12:00:09 am
Hi

@Fatih,

Thank you for your interest and enthusiasm and the TINIFile use example.

In fact I'm working on a major improvement in Android Module Wizard which will facilitate the implementation of new components.

The idea is that you will enter with the java [wrapper] class and receive the pascal component code including the jni_bridge part.

Ok. I'll try to implement Menu object.

Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on March 23, 2014, 08:34:36 am
Thanks jmpessoa for you reply.

In my opinion is very excellent work. Thanks to evaluation my request.

Good works.
Title: Re: Android Module Wizard
Post by: Sergionn on March 23, 2014, 08:33:16 pm
The idea is that you will enter with the java [wrapper] class and receive the pascal component code including the jni_bridge part.
That's great idea! can't wait when you will publish some results!
Then we shall be able to android development with more big steps into!
And thank you for your work again! It's very important especially because of firemonkey fiasco .
Don't let object pascal to be gone!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on March 27, 2014, 12:45:36 pm
Hi jmpessoa,

Can you add a new property to jEditText, BorderStyle = [bsNone, bsSingle] or similar border property?

Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 06, 2014, 08:18:52 pm

Quote
....can't wait when you will publish some results!

Yes, My work is almost done ... but now I need a little help from Linux and Mac users:  can someone send me [jmpessoa_at_hotmail_com] a executable version of "lazres" [lazarus/tools] ?

thanks in advance!
 


 
Title: Re: Android Module Wizard
Post by: Stephano on April 14, 2014, 12:14:29 am
Great work!

I am on Linux, and don't use Laz4Android, but have built Lazarus and fpc accordingly from source.

1- Libraries issue: I made a quick workaround. Ex:

Code: [Select]
{$IFDEF android}
  // jnigraphics
  function AndroidBitmap_getInfo(env: PJNIEnv; jbitmap: jobject; info: PAndroidBitmapInfo): cint;
                                     cdecl; external libjnigraphics name 'AndroidBitmap_getInfo';

 function AndroidBitmap_lockPixels(env: PJNIEnv; jbitmap: jobject; addrPtr: PPointer {void**}): cint;
                                     cdecl; external libjnigraphics name 'AndroidBitmap_lockPixels';

  function AndroidBitmap_unlockPixels(env: PJNIEnv; jbitmap: jobject): cint;
                                     cdecl; external libjnigraphics name 'AndroidBitmap_unlockPixels';
{$ELSE}
  function AndroidBitmap_getInfo(env: PJNIEnv; jbitmap: jobject; info: PAndroidBitmapInfo): cint;

 function AndroidBitmap_lockPixels(env: PJNIEnv; jbitmap: jobject; addrPtr: PPointer {void**}): cint;

  function AndroidBitmap_unlockPixels(env: PJNIEnv; jbitmap: jobject): cint;
{$ENDIF}

implementation

{$IFnDEF android}
function AndroidBitmap_getInfo(env: PJNIEnv; jbitmap: jobject;
  info: PAndroidBitmapInfo): cint;
begin
  Result := 0;
end;

function AndroidBitmap_lockPixels(env: PJNIEnv; jbitmap: jobject;
  addrPtr: PPointer): cint;
begin
  Result := 0;
end;

function AndroidBitmap_unlockPixels(env: PJNIEnv; jbitmap: jobject): cint;
begin
  Result := 0;
end;
{$ENDIF}

Another solution would be to use explicit loading of the libraries.

2- Java resources:
What are these?
I downloaded Simonsay's package. What next?

3- New project wizard: if something is missing (like ant workspace),  I get an error message, but I have to repeat the whole procedure.

4- New project wizard: For ndk ver9, there is no API level 17 which I use.

5- Why do you still use Lazarus resources instead of fpc resources?

I have other comments, but I'll keep them for later.

If you still need lazres for Linux, let me know and I'll email it to you.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 14, 2014, 04:00:39 am
@Stephano,

1. Thanks for your interest!

2. About workaround on Linux:  please, look for
   @leledumbo advices in some previous posts and in folder  .../LazAndroidWizard/linux   ("please_readme.txt"), and more generally look for "readme.txt "IV. Technical Notes:..."

3.  Java resources: What are these? Please, just point/configure to the folder   ..../LazAndroidWizard/java 
    (My modified version of simonsay's work is there! )

4. About ant workspace... just a base folder/reference for you [folder] project code. Like Eclipse Workspace...

The others questions: I will try some fix...

Thank you!

Ps. Yes, please, send me the Linux executable "lazres". I need it to produce component Icon resource.
Title: Re: Android Module Wizard
Post by: Stephano on April 14, 2014, 10:40:37 am
I saw Leledumbo's post and the readme file. The 2 solutions that I proposed are much cleaner and don't require any extra steps from the user.

I was able to make a working app, but I found more issues:

1- Don't add any options in 'other options'. Instead use the 'Paths' for -Fl -FU -o

2- Remove from other options -Xd -FL -Cf -P -dANDROID. -FL is not needed (at least Leledumbo and I don't need it), and the other options should be placed in fpc.cfg. This is debatable in order to accommodate everybody's needs.

3- The batch files are Windows only. I can help you with Linux scripts.

4- If the project name has capital letters (MyProject1), then strange errors occur.

Note: I sent you an email with the resources utilities
Title: Re: Android Module Wizard
Post by: jmpessoa on April 14, 2014, 03:06:19 pm
@Stephano,

About 1 and 2: Yes, so my priority queue  allow, I will  improve it!

About 3. Yes, You can help me! Please, send me the Linux scripts which mimics these *.bat!

About 4. Very strange indeed! I'll do some testing here...

note: yes, I received.

Thank You!

note: Please, send me the modified  *.pas with IFDEFs workaround!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on April 26, 2014, 12:34:25 pm
Hi.

When I call from main module the java function (from Controls.java), application crashes. What is problem?

Code: [Select]
procedure TfrmMain.btnClick(Sender: TObject);
  var
  s: string;
begin

  s := jSysInfo_PathDat(app.Jni.jEnv, app.Jni.jThis, App.Jni.jThis);
  // or
  s := jSysInfo_PathDat(gapp.Jni.jEnv, gapp.Jni.jThis, gapp.Jni.jThis);
  // or
  s := getPathDataBase(app.Jni.jEnv, app.Jni.jThis, App.Jni.jThis);
  ShowMessage(s);
  Exit;
end;
Title: Re: Android Module Wizard
Post by: jmpessoa on April 26, 2014, 03:19:45 pm
Hi Fatih,

Please, try my new: 

function GetFilePath(filePath: TFilePath): string;

Where:

TFilePath = (fpathNone, fpathApp, fpathData, fpathExt, fpathDCIM, fpathDataBase);

Example:

  ShowMessage(GetFilePath(fpathApp));
  ShowMessage(GetFilePath(fpathData));
  ShowMessage(GetFilePath(fpathExt));
  ShowMessage(GetFilePath(fpathDCIM));
  ShowMessage(GetFilePath(fpathDataBase));   


Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on April 27, 2014, 09:04:09 am
Hi jmpessoa.

First thanks for you reply.

But my main problem is, when i "direct call" jSysInfo_PathApp, jSysInfo_PathDat, jSysInfo_PathDataBase, jSysInfo_PathExt, jSysInfo_PathDCIM (in the And_jni_Bridge.pas file) functions from my main module, the application is crashes.

I want to write my code and improve And_jni_Bridge functions. Generally context variables (in Controls.java) causing to crash.

Any idea for this problem.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 27, 2014, 06:04:06 pm
Hi Fatih,

This is a more complicated question concerning the android API >13, so I had to rewrite a lot of code in original Simon's  "Controls.java" to overcome this difficulty .... To a better understanding of the problem, please, read some previous post when I raised this issue ....

Thank you.

EDIT 1: Refs.:
      http://forum.lazarus.freepascal.org/index.php/topic,21919.60.html
      http://android-developers.blogspot.cz/2011/11/jni-local-reference-changes-in-ics.html
Title: Re: Android Module Wizard
Post by: Stephano on April 27, 2014, 09:52:01 pm
I know we can use the Lazarus/Android jButton, but as an exercise, I want to create manually an android control using JNI and display it on the form. Example:

MyClass := ...FindClass('Landroid/widget/button')
ConstructorID := ...GetMethodID(...)
MyButton := ...NewObject(...)

How can the button be placed on the form?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 04, 2014, 01:34:17 am
Hi All,

I finally got a major update for Lazarus Android Wizard.

It Now offers two new aid/assistance to increase the productivity of coding.

1.You can now produce a almost complete pascal JNI component code from a java wrapper class!
2.You can now get assistance for produce the java warapper class!


A proof of concept: New Components [Android Bridges Extra] and Demos [Eclipse Projects]:

      jMyHello    [AppTryCode1]
      jMediaPlayer    [AppTryCode2]
 
      jTextFileManager,
                jDumpJavaMethods [AppTryCode3] //given a request and suggestion of @Stephano


Please, read the new "fast_tutorial_jni_bridges_component_create.txt" for more info!

ref: https://github.com/jmpessoa/lazandroidmodulewizard

Thanks for all!

For a first impression,  given a java wrapper class "jMyHello"

Code: [Select]
class jMyHello /*extends ...*/ {         

        private long     pascalObj = 0;      // Pascal Object
        private Controls controls  = null;   // Control Class for events
        private Context  context   = null;

        private int    mFlag;          // <<----- custom property
        private String mMsgHello = ""; // <<----- custom property
        private int[]  mBufArray;      // <<----- custom property

        public jMyHello(Controls _ctrls, long _Self, int _flag, String _hello) { //Add more '_xxx' params if needed!

          //super(_ctrls.activity);
          context   = _ctrls.activity;
          pascalObj = _Self;
          controls  = _ctrls;

          mFlag = _flag;
          mMsgHello = _hello;
          mBufArray = null;
          Log.i("jMyHello", "Create!");         
        }

        public void jFree() {
          //free local objects...
           mBufArray = null;
        }

       //write others [public] methods code here......  <<----- customs methods

        public void SetFlag(int _flag) { 
           mFlag =  _flag;   
        }

        public int GetFlag() {
           return mFlag;   
        }

        public void SetHello(String _hello) {
        mMsgHello =  _hello;   
        }

        public String GetHello() {
           return mMsgHello;   
        }
       
        public String[] GetStringArray() {
        String[] strArray = {"Helo", "Pascal", "World"};
            return strArray;   
        }
       
       
        public String[] ToUpperStringArray(String[] _msgArray) {
        int size = _msgArray.length;
        String[] resStr = new String[size];
        for (int i = 0; i < size; i++) {
        resStr[i]= _msgArray[i].toUpperCase();
        }
            return resStr;   
        }
     
        public String[] ConcatStringArray(String[]  _strArrayA, String[]  _strArrayB) {
       
        int size1 = _strArrayA.length;
        int size2 = _strArrayB.length;
       
        String[] resStr = new String[size1+size2];
       
        for (int i = 0; i < size1; i++) {
          resStr[i]= _strArrayA[i];
        }
       
        int j = size1;
        for (int i = 0; i < size2; i++) {
          resStr[j]= _strArrayB[i];
          j++;
        }
       
            return resStr;
        }
       
        public int[] GetIntArray() {
        int[] mIntArray = {1, 2, 3};
            return mIntArray;
        }

        public int[] GetSumIntArray(int[] _vA, int[] _vB, int _size) {

           mBufArray = new int[_size];

           for (int i=0; i < _size; i++) {
              mBufArray[i] = _vA[i] + _vB[i];
           }
           return mBufArray;
        }
               
        public void ShowHello() {
           Toast.makeText(controls.activity, mMsgHello, Toast.LENGTH_SHORT).show();       
        }       
}

Just a click and We can get:

Code: [Select]
unit myhello;
 
{$mode delphi}
 
interface
 
uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls;
 
type
 
{Draft Component code by "Lazarus Android Module Wizard" [5/3/2014 20:33:27]}
{https://github.com/jmpessoa/lazandroidmodulewizard}
 
{jControl template}
 
jMyHello = class(jControl)
 private
    Fflag: integer; Fhello: string;
 
 protected
 
 public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    procedure Init; override;
    function jCreate( _flag: integer; _hello: string): jObject;
    procedure jFree();
    procedure SetFlag(_flag: integer);
    function GetFlag(): integer;
    procedure SetHello(_hello: string);
    function GetHello(): string;
    function GetStringArray(): TDynArrayOfString;
    function ToUpperStringArray(var _msgArray: TDynArrayOfString): TDynArrayOfString;
    function ConcatStringArray(var _strArrayA: TDynArrayOfString; var _strArrayB: TDynArrayOfString): TDynArrayOfString;
    function GetIntArray(): TDynArrayOfInteger;
    function GetSumIntArray(var _vA: TDynArrayOfInteger; var _vB: TDynArrayOfInteger; _size: integer): TDynArrayOfInteger;
    procedure ShowHello();

 published
 
end;
 
function jMyHello_jCreate(env: PJNIEnv; this: JObject;_Self: int64; _flag: integer; _hello: string): jObject;
procedure jMyHello_jFree(env: PJNIEnv; this: JObject; _jmyhello: JObject);
procedure jMyHello_SetFlag(env: PJNIEnv; this: JObject; _jmyhello: JObject; _flag: integer);
function jMyHello_GetFlag(env: PJNIEnv; this: JObject; _jmyhello: JObject): integer;
procedure jMyHello_SetHello(env: PJNIEnv; this: JObject; _jmyhello: JObject; _hello: string);
function jMyHello_GetHello(env: PJNIEnv; this: JObject; _jmyhello: JObject): string;
function jMyHello_GetStringArray(env: PJNIEnv; this: JObject; _jmyhello: JObject): TDynArrayOfString;
function jMyHello_ToUpperStringArray(env: PJNIEnv; this: JObject; _jmyhello: JObject; var _msgArray: TDynArrayOfString): TDynArrayOfString;
function jMyHello_ConcatStringArray(env: PJNIEnv; this: JObject; _jmyhello: JObject; var _strArrayA: TDynArrayOfString; var _strArrayB: TDynArrayOfString): TDynArrayOfString;
function jMyHello_GetIntArray(env: PJNIEnv; this: JObject; _jmyhello: JObject): TDynArrayOfInteger;
function jMyHello_GetSumIntArray(env: PJNIEnv; this: JObject; _jmyhello: JObject; var _vA: TDynArrayOfInteger; var _vB: TDynArrayOfInteger; _size: integer): TDynArrayOfInteger;
procedure jMyHello_ShowHello(env: PJNIEnv; this: JObject; _jmyhello: JObject);

 
implementation
 
{---------  jMyHello  --------------}
 
constructor jMyHello.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  //your code here....
end;
 
destructor jMyHello.Destroy;
begin
  if not (csDesigning in ComponentState) then
  begin
    if jForm(Owner).App <> nil then
    begin
      if jForm(Owner).App.Initialized then
      begin
        if FjObject <> nil then
        begin
           jFree();
           FjObject:= nil;
        end;
      end;
    end;
  end;
  //you others free code here...'
  inherited Destroy;
end;
 
procedure jMyHello.Init;
begin
  if FInitialized  then Exit;
  inherited Init;
  //your code here: set/initialize create params....
  FjObject:= jCreate(Fflag ,Fhello);
  FInitialized:= True;
end;
 
 
function jMyHello.jCreate( _flag: integer; _hello: string): jObject;
begin
   Result:= jMyHello_jCreate(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis , int64(Self) ,_flag ,_hello);
end;
 
procedure jMyHello.jFree();
begin
  //in designing component state: set value here...
  if FInitialized then
     jMyHello_jFree(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject);
end;
 
procedure jMyHello.SetFlag(_flag: integer);
begin
  //in designing component state: set value here...
  if FInitialized then
     jMyHello_SetFlag(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject, _flag);
end;
 
function jMyHello.GetFlag(): integer;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_GetFlag(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject);
end;
 
procedure jMyHello.SetHello(_hello: string);
begin
  //in designing component state: set value here...
  if FInitialized then
     jMyHello_SetHello(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject, _hello);
end;
 
function jMyHello.GetHello(): string;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_GetHello(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject);
end;
 
function jMyHello.GetStringArray(): TDynArrayOfString;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_GetStringArray(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject);
end;
 
function jMyHello.ToUpperStringArray(var _msgArray: TDynArrayOfString): TDynArrayOfString;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_ToUpperStringArray(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject, _msgArray);
end;
 
function jMyHello.ConcatStringArray(var _strArrayA: TDynArrayOfString; var _strArrayB: TDynArrayOfString): TDynArrayOfString;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_ConcatStringArray(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject, _strArrayA ,_strArrayB);
end;
 
function jMyHello.GetIntArray(): TDynArrayOfInteger;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_GetIntArray(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject);
end;
 
function jMyHello.GetSumIntArray(var _vA: TDynArrayOfInteger; var _vB: TDynArrayOfInteger; _size: integer): TDynArrayOfInteger;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jMyHello_GetSumIntArray(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject, _vA ,_vB ,_size);
end;
 
procedure jMyHello.ShowHello();
begin
  //in designing component state: set value here...
  if FInitialized then
     jMyHello_ShowHello(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject);
end;
 
{-------- jMyHello_JNI_Bridge ----------}
 
function jMyHello_jCreate(env: PJNIEnv; this: JObject;_Self: int64; _flag: integer; _hello: string): jObject;
var
  jParams: array[0..2] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jParams[0].j:= _Self;
  jParams[1].i:= _flag;
  jParams[2].l:= env^.NewStringUTF(env, PChar(_hello));
  jCls:= Get_gjClass(env);
  jMethod:= env^.GetMethodID(env, jCls, 'jMyHello_jCreate', '(JILjava/lang/String;)Ljava/lang/Object;');
  Result:= env^.CallObjectMethodA(env, this, jMethod, @jParams);
  Result:= env^.NewGlobalRef(env, Result);
env^.DeleteLocalRef(env,jParams[2].l);
end;
 
(*
//Please, you need insert:
 
   public java.lang.Object jMyHello_jCreate(long _Self, int _flag, String _hello) {
      return (java.lang.Object)(new jMyHello(this,_Self,_flag,_hello));
   }
 
//to end of "public class Controls" in "Controls.java"
*)
 

procedure jMyHello_jFree(env: PJNIEnv; this: JObject; _jmyhello: JObject);
var
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'jFree', '()V');
  env^.CallVoidMethod(env, _jmyhello, jMethod);
end;
 

procedure jMyHello_SetFlag(env: PJNIEnv; this: JObject; _jmyhello: JObject; _flag: integer);
var
  jParams: array[0..0] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jParams[0].i:= _flag;
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'SetFlag', '(I)V');
  env^.CallVoidMethodA(env, _jmyhello, jMethod, @jParams);
end;
 

function jMyHello_GetFlag(env: PJNIEnv; this: JObject; _jmyhello: JObject): integer;
var
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'GetFlag', '()I');
  Result:= env^.CallIntMethod(env, _jmyhello, jMethod);
end;
 

procedure jMyHello_SetHello(env: PJNIEnv; this: JObject; _jmyhello: JObject; _hello: string);
var
  jParams: array[0..0] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jParams[0].l:= env^.NewStringUTF(env, PChar(_hello));
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'SetHello', '(Ljava/lang/String;)V');
  env^.CallVoidMethodA(env, _jmyhello, jMethod, @jParams);
env^.DeleteLocalRef(env,jParams[0].l);
end;
 

function jMyHello_GetHello(env: PJNIEnv; this: JObject; _jmyhello: JObject): string;
var
  jStr: JString;
  jBoo: JBoolean;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'GetHello', '()Ljava/lang/String;');
  jStr:= env^.CallObjectMethod(env, _jmyhello, jMethod);
  case jStr = nil of
     True : Result:= '';
     False: begin
              jBoo:= JNI_False;
              Result:= string( env^.GetStringUTFChars(env, jStr, @jBoo));
            end;
  end;
end;
 

function jMyHello_GetStringArray(env: PJNIEnv; this: JObject; _jmyhello: JObject): TDynArrayOfString;
var
  jStr: JString;
  jBoo: JBoolean;
  resultSize: integer;
  jResultArray: jObject;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
  i: integer;
begin
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'GetStringArray', '()[Ljava/lang/String;');
  jresultArray:= env^.CallObjectMethod(env, _jmyhello, jMethod);
  resultsize:= env^.GetArrayLength(env, jresultArray);
  SetLength(Result, resultsize);
  for i:= 0 to resultsize - 1 do
  begin
    jStr:= env^.GetObjectArrayElement(env, jresultArray, i);
    case jStr = nil of
       True : Result[i]:= '';
       False: begin
               jBoo:= JNI_False;
               Result[i]:= string( env^.GetStringUTFChars(env, jStr, @jBoo));
              end;
    end;
  end;
end;
 

function jMyHello_ToUpperStringArray(env: PJNIEnv; this: JObject; _jmyhello: JObject; var _msgArray: TDynArrayOfString): TDynArrayOfString;
var
  jStr: JString;
  jBoo: JBoolean;
  resultSize: integer;
  jResultArray: jObject;
  jParams: array[0..0] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
  newSize0: integer;
  jNewArray0: jObject=nil;
  i: integer;
begin
  newSize0:= ?
  jNewArray0:= env^.NewObjectArray(env, newSize0, env^.FindClass(env,'java/lang/String'),env^.NewStringUTF(env, PChar('')));
  for i:= 0 to newSize0 - 1 do
  begin
     env^.SetObjectArrayElement(env,jNewArray0,i,env^.NewStringUTF(env, PChar(_msgArray[i])));
  end;
  jParams[0].l:= jNewArray0;
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'ToUpperStringArray', '([Ljava/lang/String;)[Ljava/lang/String;');
  jResultArray:= env^.CallObjectMethodA(env, _jmyhello, jMethod,  @jParams);
  resultSize:= env^.GetArrayLength(env, jResultArray);
  SetLength(Result, resultSize);
  for i:= 0 to resultsize - 1 do
  begin
    jStr:= env^.GetObjectArrayElement(env, jresultArray, i);
    case jStr = nil of
       True : Result[i]:= '';
       False: begin
                jBoo:= JNI_False;
                Result[i]:= string( env^.GetStringUTFChars(env, jStr, @jBoo));
              end;
    end;
  end;
env^.DeleteLocalRef(env,jParams[0].l);
end;
 

function jMyHello_ConcatStringArray(env: PJNIEnv; this: JObject; _jmyhello: JObject; var _strArrayA: TDynArrayOfString; var _strArrayB: TDynArrayOfString): TDynArrayOfString;
var
  jStr: JString;
  jBoo: JBoolean;
  resultSize: integer;
  jResultArray: jObject;
  jParams: array[0..1] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
  newSize0: integer;
  jNewArray0: jObject=nil;
  newSize1: integer;
  jNewArray1: jObject=nil;
  i: integer;
begin
  newSize0:= ?
  jNewArray0:= env^.NewObjectArray(env, newSize0, env^.FindClass(env,'java/lang/String'),env^.NewStringUTF(env, PChar('')));
  for i:= 0 to newSize0 - 1 do
  begin
     env^.SetObjectArrayElement(env,jNewArray0,i,env^.NewStringUTF(env, PChar(_strArrayA[i])));
  end;
  jParams[0].l:= jNewArray0;
  newSize1:= ?
  jNewArray1:= env^.NewObjectArray(env, newSize0, env^.FindClass(env,'java/lang/String'),env^.NewStringUTF(env, PChar('')));
  for i:= 0 to newSize1 - 1 do
  begin
     env^.SetObjectArrayElement(env,jNewArray1,i,env^.NewStringUTF(env, PChar(_strArrayB[i])));
  end;
  jParams[1].l:= jNewArray1;
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'ConcatStringArray', '([Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String;');
  jResultArray:= env^.CallObjectMethodA(env, _jmyhello, jMethod,  @jParams);
  resultSize:= env^.GetArrayLength(env, jResultArray);
  SetLength(Result, resultSize);
  for i:= 0 to resultsize - 1 do
  begin
    jStr:= env^.GetObjectArrayElement(env, jresultArray, i);
    case jStr = nil of
       True : Result[i]:= '';
       False: begin
                jBoo:= JNI_False;
                Result[i]:= string( env^.GetStringUTFChars(env, jStr, @jBoo));
              end;
    end;
  end;
env^.DeleteLocalRef(env,jParams[0].l);
  env^.DeleteLocalRef(env,jParams[1].l);
end;
 

function jMyHello_GetIntArray(env: PJNIEnv; this: JObject; _jmyhello: JObject): TDynArrayOfInteger;
var
  resultSize: integer;
  jResultArray: jObject;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'GetIntArray', '()[I');
  jresultArray:= env^.CallObjectMethod(env, _jmyhello, jMethod);
  resultsize:= env^.GetArrayLength(env, jresultArray);
  SetLength(Result, resultsize);
  env^.GetIntArrayRegion(env, jResultArray, 0, resultSize, @Result[0] {target});
end;
 

function jMyHello_GetSumIntArray(env: PJNIEnv; this: JObject; _jmyhello: JObject; var _vA: TDynArrayOfInteger; var _vB: TDynArrayOfInteger; _size: integer): TDynArrayOfInteger;
var
  resultSize: integer;
  jResultArray: jObject;
  jParams: array[0..2] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
  newSize0: integer;
  jNewArray0: jObject=nil;
  newSize1: integer;
  jNewArray1: jObject=nil;
begin
  newSize0:= ?
  jNewArray0:= env^.NewIntArray(env, newSize0);  // allocate
  env^.SetIntArrayRegion(env, jNewArray0, 0 , newSize0, @_vA[0] {source});
  jParams[0].l:= jNewArray0;
  newSize1:= ?
  jNewArray1:= env^.NewIntArray(env, newSize1);  // allocate
  env^.SetIntArrayRegion(env, jNewArray1, 0 , newSize1, @_vB[0] {source});
  jParams[1].l:= jNewArray1;
  jParams[2].i:= _size;
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'GetSumIntArray', '([I[II)[I');
  jResultArray:= env^.CallObjectMethodA(env, _jmyhello, jMethod,  @jParams);
  resultSize:= env^.GetArrayLength(env, jResultArray);
  SetLength(Result, resultSize);
  env^.GetIntArrayRegion(env, jResultArray, 0, resultSize, @Result[0] {target});
  env^.DeleteLocalRef(env,jParams[0].l);
  env^.DeleteLocalRef(env,jParams[1].l);
end;
 
procedure jMyHello_ShowHello(env: PJNIEnv; this: JObject; _jmyhello: JObject);
var
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jCls:= env^.GetObjectClass(env, _jmyhello);
  jMethod:= env^.GetMethodID(env, jCls, 'ShowHello', '()V');
  env^.CallVoidMethod(env, _jmyhello, jMethod);
end;
 
end.

Title: Re: Android Module Wizard
Post by: jmpessoa on May 07, 2014, 03:27:51 am
Hi,

Given a suggestion and request by Fatih KILIÇ ... I made a minor update
of  Android Module Wizard....

Now the Version 0.5 {rev. 01 - 06 May 2014} Add Partial Support for Menu Object [Option Menu/SubMenu and Context Menu]....

      :: NEW jMenu Component [Android Bridges Extra]
      :: NEW AppMenuDemo [Eclipse Project]

Please, ref: https://github.com/jmpessoa/lazandroidmodulewizard

Thanks!

PS.

@Stephano: first we would need to define a new architecture: application model, form model and component model.... soon as possible I will try to investigate the way that you propose. Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on May 07, 2014, 09:29:52 am
Hi jmpessoa.

I have tested AppMenuDemo eclipse project. Very good work for me. Thank you for your evaluates my suggestion and request.


Note:

When I select menu from title bar the menu and submenu is works fine, but when i select menu from hardware MENU button the submenu can't dispayed.
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on May 07, 2014, 09:33:04 am
Also, i examine your wrapper class. Really that very big work. Good works.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 08, 2014, 02:45:55 pm

@ Fatih KILIÇ

Code: [Select]
....when i select menu from hardware MENU button the submenu can't dispayed....

Yes, the support for icon/drawable is very partial....

Please, verify that you have "ic_launcher.png" in all  ....\res\drawable-xxxx  folders.

Thank you.
Title: Re: Android Module Wizard
Post by: Leledumbo on June 07, 2014, 07:16:41 pm
Latest commit (may 8th) + today's lazarus svn causes access violation whenever I drop any control. Best stack trace I can get:
Quote
AddComponent jTextView Parent=MainModule:TMainModule 164,103,0,0
Parent is 'nil'
TMainIDE.OnPropHookPersistentAdded A jTextView1:jTextView
[TEventsCodeTool.CompleteComponent]  CurComponent=jTextView1:jTextView

Program received signal SIGSEGV, Segmentation fault.
0x0000000000891747 in CUSTOMFORMEDITOR$_$TCUSTOMFORMEDITOR_$__$$_DOONNODEGETIMAGEINDEX$TPERSISTENT$LONGINT ()
(gdb) bt
#0  0x0000000000891747 in CUSTOMFORMEDITOR$_$TCUSTOMFORMEDITOR_$__$$_DOONNODEGETIMAGEINDEX$TPERSISTENT$LONGINT ()
#1  0x00007fffdafc7d40 in ?? ()
#2  0x00007fffdbeadbc0 in ?? ()
#3  0x00007fffdbf50410 in ?? ()
#4  0x00000000007c6f9f in OBJECTINSPECTOR$_$TOBJECTINSPECTORDLG_$__$$_COMPONENTTREEGETNODEIMAGEINDEX$TPERSISTENT$LONGINT ()
#5  0x0000000000000001 in ?? ()
#6  0x0000000000cbf6b4 in COMPONENTTREEVIEW$_$TCOMPONENTTREEVIEW_$__$$_GETIMAGEFOR$TPERSISTENT$$LONGINT ()
#7  0x0000000000000001 in ?? ()
#8  0x00007fffdbeadbc0 in ?? ()
#9  0x00007fffdb631c00 in ?? ()
#10 0x0000000000cbe3ff in COMPONENTTREEVIEW$_$TCOMPONENTWALKER_$__$$_WALK$TCOMPONENT ()
#11 0x00007fffffffc708 in ?? ()
#12 0x00007fffffffc7f8 in ?? ()
---Type <return> to continue, or q <return> to quit---
#13 0x00007fff00000001 in ?? ()
#14 0x00007fffdb631c00 in ?? ()
#15 0x00007fffffffc7c0 in ?? ()
#16 0x00007fffdbeadbc0 in ?? ()
#17 0x00007fffdbeadbc0 in ?? ()
#18 0x00007ffff7fc34c0 in ?? ()
#19 0x00007fffffffd800 in ?? ()
#20 0x00007fffffffc6f0 in ?? ()
#21 0x0000000000cbe345 in COMPONENTTREEVIEW$_$TCOMPONENTWALKER_$__$$_WALK$TCOMPONENT ()
#22 0x0000000000000000 in ?? ()
Title: Re: Android Module Wizard
Post by: jmpessoa on June 07, 2014, 08:19:54 pm
Ok,

I'll try to see what's happening....

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on June 08, 2014, 01:08:21 pm
Works fine in 1.2.2, so I guess it's something changed in svn. It's up to you though, whether you want to make it compatible or not.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 08, 2014, 07:13:54 pm
Good News!

Thank you!

PS. I am working in next generation: the form designer is on the way!
Title: Re: Android Module Wizard
Post by: Stephano on June 09, 2014, 12:33:58 am
@Leledumbo,

Did you recompile the IDE clean? I did and the IDE aborts the compilation (panic).
Title: Re: Android Module Wizard
Post by: Leledumbo on June 09, 2014, 12:20:33 pm
@Leledumbo,

Did you recompile the IDE clean? I did and the IDE aborts the compilation (panic).
Yes, I build from fresh svn source and fresh 1.2.2 source using FPC 2.7.1 of quite recent (no less than a week) revision.
Title: Re: Android Module Wizard
Post by: Stephano on June 09, 2014, 04:59:16 pm
i used svn from 2 days ago. The IDE fails to build when this package is installed.
Title: Re: Android Module Wizard
Post by: Leledumbo on June 09, 2014, 06:21:55 pm
Probably just an intermittent bug. Anyway, since it doesn't work as well in lazarus svn, you don't have to try further. Stick with 1.2.2 instead.
Title: Re: Android Module Wizard
Post by: Stephano on June 09, 2014, 09:32:39 pm
Stable versions are for the faint hearted  :D

I hope this gets fixed soon.
Title: Re: Android Module Wizard
Post by: Leledumbo on June 11, 2014, 06:17:06 pm
@jmpessoa,

First, are you going to concentrate on the visual designer and abandon the existing lazandroidmodule? Or will it be another package that depends on lazandroidmodule?

Second, I have found a (probably) bug. wgRadioButton in ListView doesn't act like a radio button. Selecting one doesn't deselect the others and there's no way to set checked state from code. I see Java code for this in Controls.java but jListView hasn't wrapped the method yet.

Third, will you add Spinner? I need a combobox like structure. Right now, I have to abuse list view a bit.

Last but not least, how do you create user defined dialog?
Title: Re: Android Module Wizard
Post by: jmpessoa on June 11, 2014, 07:02:56 pm
Hi Leledumbo,

1. No, I am not will abandon the existing lazandroidmodule. The existents projects will load in the next generation.

2. I will return to jListView  code and try fix this bug.

3. I wil try implement the Spinner.

4. how do you create user defined dialog? The paradigm is the same: Java warapper (added to "controls.java") and Pascal "bridge" Component. I Will try
implement an example.

Thank you!

PS: "For all"

Just of curiosity : Someone tried to build your own component?

Lazarus Android Wizard now offers two new aid/assistance to increase the productivity of coding.

1.You can now produce a almost complete pascal JNI component code from a java wrapper class!
2.You can now get assistance for produce the java warapper class!

Please, read the new "fast_tutorial_jni_bridges_component_create.txt" for more info!


EDIT_1 :: Rapid fix to jListView :: "Controls.java"

ref. line 1779:
Code: [Select]
class jListItemRow{
String label;
int    id;
int widget = 0;

       //Added code :: needed to fix  the RadioButton Group default behavior: thanks to

View jWidget;  // << Added here !!!
      ...........
      ...........
}


ref: line 2014::
View.OnClickListener getOnCheckItem(final View cb, final int position)                 
Code: [Select]
......
......
else if (cb.getClass().getName().equals("android.widget.RadioButton")) {

//new code: fix to RadioButton Group  default behavior: thanks to Leledumbo.

boolean doCheck = ((RadioButton)cb).isChecked(); //new code                                                    
for (int i=0; i < items.size(); i++) {
   ((RadioButton)items.get(i).jWidget).setChecked(false);
   items.get(i).checked = false;                  
}
                 
items.get(position).checked = doCheck;
((RadioButton)cb).setChecked(doCheck);                                      
controls.pOnClickWidgetItem(PasObj, position, ((RadioButton)cb).isChecked());                  
} //end else to "android.widget.RadioButton"
.....
....
Title: Re: Android Module Wizard
Post by: jmpessoa on June 14, 2014, 06:52:04 am
Hi All!

I did an update "Android Module Wizard"

  :: New Add [Partial] Support for Spinner Object //<<---- A suggestion and request by Leledumbo
      :: NEW jSpinner Component [Android Bridges EXtra]
      :: NEW AppSpinnerDemo [Eclipse Project]

      :: NEW AppListViewDemo [Eclipse Project]
         fix RadioButton behavior...//<<---- A suggestion and request by Leledumbo

      :: Warning: Bluetooth support yet unfinished! [BUG?]!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!
Title: Re: Android Module Wizard
Post by: Leledumbo on June 14, 2014, 08:19:11 pm
Thanks for the update. One more thing, could you research on how to handle Java exceptions? ATM, every Java exception will crash the app so we need a mechanism to handle it. Pascal exceptions can of course be handled by Pascal code.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 15, 2014, 01:37:03 am
@Leledumbo [and All],

OK. Have you some new component requirement?

Thanks!
Title: Re: Android Module Wizard
Post by: Leledumbo on June 15, 2014, 04:55:15 am
@Leledumbo [and All],

OK. Have you some new component requirement?

Thanks!
Hmm...not yet so far, just that exception handling.
I have a little improvement idea, not in the code, but the build process. You can run ProGuard (http://proguard.sourceforge.net/) since not all classes, methods, etc. are used. This can reduce the final result size.
I want to ask one thing, how to use toast? It's a bit unclear to me. It should be a class with class method in the Android Java documentation.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 19, 2014, 02:59:11 pm
@Leledumbo,

Code: [Select]
....You can run ProGuard since not all classes...

Nice! great info!

Quote
how to use toast?

I implemented the standard "ShowMessage" as a jForm method:
 
line: 417
Code: [Select]
public void ShowMessage(String msg){
Log.i("ShowMessage:", msg);
    Toast.makeText(controls.activity, msg, Toast.LENGTH_SHORT).show();
}

Where "controls.activity"  is the "fresh"  java Context  maintained over the entire framework designer ...

You can put this code:
Code: [Select]
Toast.makeText(controls.activity, "my message", Toast.LENGTH_SHORT).show();
   
 inside any method for other jobjects in "Controls.java"! See lines 5024/5120 [jMyHello]

For jForm Pascal side there is:

Quote
procedure jForm.ShowMessage(msg: string);
begin
  UpdateJNI(gApp);  // << ---- "refresh" Context!
  jForm_ShowMessage(Self.App.Jni.jEnv, Self.App.Jni.jThis,  FjObject, msg);
end;

Where the last is the Pascal JNI API:

Code: [Select]
procedure jForm_ShowMessage(env:PJNIEnv; this:jobject; Form:jObject; msg: string);
var
   cls: jClass;
   method: jmethodID;
    _jParams : Array[0..0] of jValue;
begin
   _jParams[0].l:= env^.NewStringUTF(env, pchar(msg) );
  cls := env^.GetObjectClass(env, Form);
  method:= env^.GetMethodID(env, cls, 'ShowMessage', '(Ljava/lang/String;)V');env^.CallVoidMethodA(env,            Form, method,@_jParams);
  env^.DeleteLocalRef(env,_jParams[0].l);
end;

Thank you!

PS1. In future we may consider including  in the template "Controls.java" [in designe time] only the classes used by project... so we will have more custom Apps.

PS2. The next generation [form designer] is coming soon! Will be much more fun to program for android! :D
Title: Turkish Character View Problem
Post by: Fatih KILIÇ on July 09, 2014, 10:54:30 am
Hi,

When I set jTextView.Text property by turkish characters set, the characters's view is incorrect. Is this a bug?

How do I solve this problem?

Note: The .pas file is saved in UTF8 format.

Code: [Select]
jTextView.Text := 'İETT Otobüs Sefer Bilgisi (iettosb), İETT''nin yurt içi taşımacılığı...';

Screen View:
İETT Otobüs Sefer Bilgisi (iettosb), İETT''nin yurt içi taşımacılığı' +
Title: Re: Android Module Wizard
Post by: tk on July 09, 2014, 02:02:54 pm
Source file encoding must be UTF8. Try with our without BOM. Debug in assembly. Check if there is no conversion routine called like fpc_ansi_str* or similar.
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on July 09, 2014, 02:37:27 pm
Thanks tk. As you said, I removed related section and problem solved.

File: Laz_And_Controls.pas

Code: [Select]
Procedure jTextView.SetText(Value: string);
begin
  FText:= Value; //utf8encode(Value);  // Removed.
  if FInitialized then
    jTextView_setText2(jForm(Owner).App.Jni.jEnv, jForm(Owner).App.Jni.jThis, FjObject, FText);
end;
Title: Get/Set Data
Post by: Fatih KILIÇ on July 23, 2014, 09:33:48 pm
Hi, jmpessoa.

1. Can you adapt below java code or improved related function to the Android Module Wizard in the fashion GetIntData, SetIntData, GetStringData, SetStringData, GetBoolData, SetBoolData?

2. Can you add GPS component to the Android Module Wizard?

Thanks.

Code: [Select]
private static int getIntData(Context context, String Key, int defValue) {

SharedPreferences sPref = PreferenceManager
.getDefaultSharedPreferences(context);

return sPref.getInt(Key, defValue);
}

private static void setIntData(Context context, String Key, int Value) {

SharedPreferences sPref = PreferenceManager
.getDefaultSharedPreferences(context);

SharedPreferences.Editor edt = sPref.edit();
edt.putInt(Key, Value);
edt.commit();
}

private static String getStringData(Context context, String Key, String defValue) {

SharedPreferences sPref = PreferenceManager
.getDefaultSharedPreferences(context);

return sPref.getString(Key, defValue);
}

private static void setStringData(Context context, String Key, String Value) {

SharedPreferences sPref = PreferenceManager
.getDefaultSharedPreferences(context);

SharedPreferences.Editor edt = sPref.edit();
edt.putString(Key, Value);
edt.commit();
}

private static boolean getBoolData(Context context, String Key, boolean defValue) {

SharedPreferences sPref = PreferenceManager
.getDefaultSharedPreferences(context);

return sPref.getBoolean(Key, defValue);
}

private static void setBoolData(Context context, String Key, boolean Value) {

SharedPreferences sPref = PreferenceManager
.getDefaultSharedPreferences(context);

SharedPreferences.Editor edt = sPref.edit();
edt.putBoolean(Key, Value);
edt.commit();
}
Title: Re: Android Module Wizard
Post by: jmpessoa on July 23, 2014, 11:42:55 pm
Ok Fatih , I will try!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on August 18, 2014, 06:10:31 am
Hi All!

There is an updated version of "Android Module Wizard"

      :: New jLocation Component: Add Partial Support for Location Object //<<---- A suggestion and request by Fatih KILIÇ

      :: New jPreference Component: Add Partial Support for Preferences Object //<<---- A suggestion and request by Fatih KILIÇ

      :: NEW AppLocationDemo [Eclipse Project]  --- see picture attached


ref. https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!
Title: Re: Android Module Wizard
Post by: Leledumbo on August 18, 2014, 06:29:35 am
Hi All!

There is an updated version of "Android Module Wizard"

      :: New jLocation Component: Add Partial Support for Location Object //<<---- A suggestion and request by Fatih KILIÇ

      :: New jPreference Component: Add Partial Support for Preferences Object //<<---- A suggestion and request by Fatih KILIÇ

      :: NEW AppLocationDemo [Eclipse Project]  --- see picture attached


ref. https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!
Congratulations! How's the GUI designer progress?
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on August 20, 2014, 10:02:31 am
Thanks jmpessoa for taking valuable time.

Become a beautiful work.

I wish you continued efforts.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 02, 2014, 09:16:21 pm
Hi!

Code: [Select]
...How's the GUI designer progress?
I'm still working .... you can already see some results [attached figures]

Thanks!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on September 04, 2014, 11:51:00 am
Hi.

Q1.
My there are two form. First form (TAndroidModule1) opens second form (TAndroidModule3). Second form must result value to the first form. Below codes is insufficient. How two form are synchronize the value? (global.SelectedHat)

Form1
Code: [Select]
procedure TAndroidModule1.DataModuleClickContextMenuItem(Sender: TObject;
  jObjMenuItem: jObject; itemID: integer; itemCaption: string; checked: boolean
  );
begin

  if(itemID = 10) then
  begin

    if(AndroidModule3 = nil) then
    begin

      gApp.CreateForm(TAndroidModule3, AndroidModule3);
      AndroidModule3.Init(gApp);
    end else AndroidModule3.Show;
  end;

  // global variable
  edtHat.Text := global.SelectedHat;
end;

Form2
Code: [Select]
procedure TAndroidModule3.jListView1ClickCaptionItem(Sender: TObject;
  Item: integer; caption: string);
begin

  // global variable
  global.SelectedHat := caption;

  Close;
end;

Q2:
Second problem is when add item jListView above 512 the program is crach. Error is: "E/dalvikvm(3819): Failed adding to JNI local ref table (has 512 entries)"

How resolve these problem. Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 06, 2014, 05:34:05 am
Hi Fatih,

Q1. :: I Added Unit "global" for TAndroidModule1 unit AND for TAndroidModule3 unit: my test was OK!!!

Q2: In line "6355" of  "And_jni_Bridge.pas", See my code and the FIX:

Code: [Select]
Procedure jListView_add2(env:PJNIEnv;this:jobject; ListView: jObject; Str: string; delimiter: string);
var
  _jMethod: jMethodID = nil;
  _jParams: array[0..1] of jValue;
  cls: jClass;
begin
  _jParams[0].l := env^.NewStringUTF(env, pchar(Str) );
  _jParams[1].l := env^.NewStringUTF(env, pchar(delimiter) );
  cls := env^.GetObjectClass(env, ListView);
  _jMethod:= env^.GetMethodID(env, cls, 'add2', '(Ljava/lang/String;Ljava/lang/String;)V');
  env^.CallVoidMethodA(env,ListView,_jMethod,@_jParams);
  env^.DeleteLocalRef(env,_jParams[0].l);
  env^.DeleteLocalRef(env,_jParams[1].l);
  env^.DeleteLocalRef(env, cls);  // <---- Added this for bug fix! 09-Sept-2014 [Thanks to  @Fatih!]
end;   

Please, do this for others jListView_add* too!

Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on September 06, 2014, 10:16:07 am
Thanks jmpessoa

jListView1.Add problem is solved. Also i'm waiting updated lazandroidmodule for global unit.

A suggestion: improving of ListView widget will helpful.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 06, 2014, 02:09:32 pm
Hi Fatih, about Q1:

No, there will be NO update for global unit .... I just tried to redo the path that you were trying to do .... and managed to get the expected result! For test  I just used this code:

Code: [Select]
unit Global;

{$mode delphi}

interface

uses
  Classes, SysUtils;

var

  SelectedHat: string;

implementation

end.

Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on September 07, 2014, 10:13:18 am
Hi, jmpessoa

When I click TAndroidModule3.jListView (TAndroidModule3.jListView1ClickCaptionItem) the Form2 (TAndroidModule3) is closed, global.SelectedHat variable is empty and edtHat.Text (jEditText) control value is showing blank value.

I think there are synchronize problem? I could not find a solution.

Thank you.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 07, 2014, 08:52:28 pm
Hi Fatih, please, try this:
 
Code: [Select]
Unit3

interface
 
............................
............................

implementation

uses Unit1;   //< ------ put it!

procedure TAndroidModule3.jListView1ClickCaptionItem(Sender: TObject;
  Item: integer; caption: string);
begin

  // global variable
  global.SelectedHat := caption;

  Unit1.edtHat.Text := global.SelectedHat;  ////< ------ put it!

  Close;
end;

Thank you!

PS. As soon as possible, I will try a more architectural synchronization solution!

EDITED: Ok, here's a more elegant solution:

Code: [Select]
TAndroidModule1 = class(jForm)

    private
      {private declarations}
    public
      {public declarations}
      Procedure MyCallBack(Sender: TObject);  //<--- your call back function!
end; 

implementation

Procedure TAndroidModule1.MyCallBack(Sender: TObject);
begin
   jEditText1.Text:= global.SelectedHat;
end; 

procedure TAndroidModule1.DataModuleClickContextMenuItem(Sender: TObject;
  jObjMenuItem: jObject; itemID: integer; itemCaption: string; checked: boolean);
begin

  if(itemID = 10) then
  begin

    if(AndroidModule3 = nil) then
    begin
        gApp.CreateForm(TAndroidModule3, AndroidModule3);
        AndroidModule3.SetCloseCallBack(MyCallBack, nil);  //<<-- [delphi sintaxe mode]!
        AndroidModule3.Init(gApp);
    end else AndroidModule3.Show;
  end;

  // global variable
  //edtHat.Text := global.SelectedHat; //<<---- this line never was called!
end;


Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on September 08, 2014, 10:00:52 am
Hi, jmpessoa.

Different and interesting a solution but synchronization solution is more beautiful.

I wish you continued your work.

Thank you.

========================
NOTE: LATER ADDED SECTION

Bug: EditText1Change events is not triggers.

Code: [Select]
procedure TAndroidModule3.jEditText1Change(Sender: TObject;
  EventType: TChangeType);
begin

  case EventType of

    ctChangeBefore: ShowMessage('ctChangeBefore event occurs');
    ctChange: ShowMessage('ctChange event occurs');
    ctChangeAfter: ShowMessage('ctChangeAfter event occurs');
  end;
end;
Title: Re: Android Module Wizard
Post by: Leledumbo on September 14, 2014, 01:34:02 pm
I add a readme.md for easier reading in the github page, the readme.txt looks clumsy to me.
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 17, 2014, 06:03:08 pm
why it show me 'src folder not found'  ?
 Project -> New Project
 JNI Android Module
 Next...
 show error....

another question: when will have form designer?is it in this year?
Title: Re: Android Module Wizard
Post by: jmpessoa on September 17, 2014, 06:41:20 pm
Hi greenzyzyzy,

Q1: the " Next..." is a form like this (?!):

http://jmpessoa.opendrive.com/files?Ml8zNzM2NzE1OV9YdHJXaw

--"Path to Workplace" ?
--"Selected"  project  Name ?
-- Eclipse or Ant Project?

Please, see:

"fast_tutorial_eclipse_users.txt" and/or
"fast_tutorial_ant_users.txt" and/or

Q2:  Very soon!

Thank you!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 17, 2014, 06:54:09 pm
error show after 'Select java source' this form,press ok then show error.
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on September 17, 2014, 09:02:46 pm
Hi, greenzyzyzy.

Please watch below video.

http://www.youtube.com/watch?v=sQnFYJyltwY&list=UUkQrLhaIXrKY4eq9zTymxpQ (http://www.youtube.com/watch?v=sQnFYJyltwY&list=UUkQrLhaIXrKY4eq9zTymxpQ)
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 18, 2014, 04:40:18 am
thanks jmpessoa and Fatih KILIÇ, problem solved.
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 18, 2014, 06:22:48 am
Q1:does Android Module Wizard can use TBitmap?not jBitmap.

Q2:does Android Module Wizard can use any other laz4android lcl?
Title: Re: Android Module Wizard
Post by: jmpessoa on September 18, 2014, 06:38:01 pm
Hi greenzyzyzy,

In my experiments, all LCL dependencies failed!

Thank you!

PS. LCLBase ( LResources) is OK, for component icon!
      flc-image is OK!
      freetype is OK (please, see in this forum!)
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 19, 2014, 04:33:03 am
Hi greenzyzyzy,

In my experiments, all LCL dependencies failed!

Thank you!

PS. LCLBase ( LResources) is OK, for component icon!
      flc-image is OK!
      freetype is OK (please, see in this forum!)


some of Android Module Wizard components' property and method is missing ,will add them?for example jbitmap is not have savetostream
and loadfromstream.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 21, 2014, 12:32:01 am
Yes, greenzyzyzy

Whenever possible (time is always a important variable ...) I will implement new methods and properties to all components...

Specifically, if you point out the context in which you need to use jbitmap it would be important. I can try implement your request...

Thank you!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 21, 2014, 12:45:32 pm
thanks for your work!nothing  important i need.i only hope your program will be perfect.
Title: Re: Android Module Wizard
Post by: Stygian on September 25, 2014, 08:15:30 am
Hello,

I have a question about Laz4android. Can I use the offical build Lazarus(now 1.2.4 with FPC 2.6.4)?
Or you build is a must.

Thanks,
Stygian
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 25, 2014, 04:46:52 pm
sorry i do not know,because i am a newer too.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 25, 2014, 06:23:06 pm
No,  You will need fpc 2.7.1 + cross arm/x86  libs for android.....

the simplest way is to get this one:

https://sourceforge.net/projects/laz4android/files/?source=navbar

--->>>    win32/Android NDK-9/{ARM and x86 !} :: Thanks to TrueTom!

Welcome!

Title: Re: Android Module Wizard
Post by: Leledumbo on September 25, 2014, 06:37:29 pm
Can I use the offical build Lazarus(now 1.2.4 with FPC 2.6.4)?
Lazarus 1.2.4 is OK, but FPC must be 2.7.1 since 2.6.4 contains no proper Android support.
Title: Re: Android Module Wizard
Post by: Stygian on September 25, 2014, 07:50:13 pm
Thanks for the answer. Maybe others already said it but there is a bug in the Android Modul configure window. The Ant and SDK browse buttons are swapped.
Title: Re: Android Module Wizard
Post by: greenzyzyzy on September 27, 2014, 11:20:54 am
Hi greenzyzyzy,

In my experiments, all LCL dependencies failed!

Thank you!

PS. LCLBase ( LResources) is OK, for component icon!
      flc-image is OK!
      freetype is OK (please, see in this forum!)


old question,does TBitmap or TMemoryStream can use in Android Module Wizard?
it seems it is compiled ok.but i have not test.have you test?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 02, 2014, 07:20:13 pm
Hi!

I'm preparing a major change for Android Module Wizard: the form designer is here!

However, before upgrading the github repository, I would like some feedback, mainly due to compatibility issues!

   :: New Android Widgets Fom Designer! //<<--- thanks to LiteZarus by x2nie!

      -->> Windows Users: Get LiteZarus4Android [Lazarus 1.3 + x2nie patch [No LCLform design] + TrueTom fpc 2.7.1 cross Arm/x86/android/]

                        ::To Install, please, read the "LiteZarus4Android_readme.txt"

      Download from: [EDITED!]

                https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21236
         
      -->> Linux Users: Get Lazarus 1.3 rev >= 45216,45217 ... and fpc 2.7.1 cross /arm/x86/android ... etc
     
   1. Guide line for "Old" Projects [Collateral Effects] --- *Please make a backup* !!

      -->> Some TAndroidModule form properties was supressed!

         Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading" !

      -->> Components conteiners behavior [jPanel e jScrollView] :  remove and put [again] yours controls into them!
                 
      -->> Now adjust yours widgets, the concept continue the same:

         .LayoutParamWidth/LayoutParamHeight
         .Anchor
         .PosRelativeToAnchor
         .PosRelativeToParent

      -->> Add new "AndroidWidget" unit to uses clauses [*.dpr/*.pas]

   2. NEWS !!
   
      -->> The form *.lfm parse now is OK !!!

      -->> AppTest1 [eclipse project] :: jPanel and form close/callback demo...

                      form1 design : https://jmpessoa.opendrive.com/files?Ml82NTQ0NDMxNl9CV292dg
                      form1 Screen : https://jmpessoa.opendrive.com/files?Ml82NTQ0NDM2OV9SUVJ1NA

                      form2 design : https://jmpessoa.opendrive.com/files?Ml82NTQ0Nzk5N19RbXFjVw
                      form2 Screen : https://jmpessoa.opendrive.com/files?Ml82NTQ0NzQ3NF9wMGhHcQ
                     
      -->> AppCameraDemo [eclipse project] :: jPanel and jCamera demo

      -->> AppDemo1 [eclipse project] was adjusted/updated !     

   3. Download  "NEW" Android Module Wizard - version 0.6: [EDITED!]
 
       https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21237

   4. Download  demos: [EDITED!]
            https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21238


Thanks to All!
Title: Re: Android Module Wizard
Post by: luri on October 03, 2014, 04:17:13 am
all download link: "This item might not exist or is no longer available"
Title: Re: Android Module Wizard
Post by: jmpessoa on October 03, 2014, 05:14:39 am
Hi luri,  I Edited the links!

Thank you!
Title: Re: Android Module Wizard
Post by: xinyiman on October 04, 2014, 08:06:24 pm
Sorry, but I can not find clear documentation and well-argued on this topic.

How to start from scratch?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 04, 2014, 08:41:04 pm
Hi xinyiman, there are:

"readme.txt"

"fast_tutorial_eclipse_users.txt"

"fast_tutorial_ant_users.txt"

ref. folder "LazAndroidWizard"  [ https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21237]

But If you can enumerate your questions I can try to help!

Welcome!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on October 10, 2014, 03:03:32 pm
Hi xinyiman, there are:

"readme.txt"

"fast_tutorial_eclipse_users.txt"

"fast_tutorial_ant_users.txt"

ref. folder "LazAndroidWizard"  [ https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21237]

But If you can enumerate your questions I can try to help!

Welcome!


sorry , i can not open this link.
can you add the program to https://github.com/jmpessoa/lazandroidmodulewizard  ?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 10, 2014, 06:33:56 pm
Hi  greenzyzyzy, can you try this?

https://jmpessoa.opendrive.com/files?Ml82NTcyMDQ3MV84bEk5bQ

or

https://www.mediafire.com/?cuban3u110gnolb


I'll try to do an GITHUB update later this week ....

The demos is here:

http://www.mediafire.com/download/y6w8pie3h1k15ux/demos_eclipse_projects_02_october_2014.rar


Thank you!

Title: Re: Android Module Wizard
Post by: thierrydijoux on October 11, 2014, 12:19:47 pm
Hi,
I played with android during 1 week, using Android Module Wizard.
Very nice tool !
I'm using the ant process to compile and build apk.
I have questions about themes. I'm trying using the Holo theme light, but i always have froyo style interfaces. Did someone succeeded to apply native theme (i targeted android 4.4 in sdk target).
And what about strings.xml, i don't know if it's possible to get values from strings.xml to have multi language interfaces. If it's possible and if someone has a piece of code to show...
Thanks in advance
Title: Re: Android Module Wizard
Post by: Leledumbo on October 11, 2014, 05:12:03 pm
And what about strings.xml, i don't know if it's possible to get values from strings.xml to have multi language interfaces. If it's possible and if someone has a piece of code to show...
Thanks in advance
Since AMW use LCL style resources, I think you should use the same approach for multilingual apps. The same way as the desktop apps. The problem is everytime you change strings.xml, R.java is automatically regenerated and you will need a dynamic JNI wrapper to be able to call the entries in the R class. It's not impossible, but you will need R.java JNI wrapper.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 11, 2014, 06:03:28 pm
Hi,

@thierrydijoux,

You can try modify this line,

Code: [Select]
android:theme="@style/AppTheme" >

in "AndroidManifest.xml"

Well, You can try change "styles.xml" too:  [ .....\res\values\styles.xml ]

@Leledumbo, you got played with new "form designer" version?  ;D

Thanks!
 

Title: Re: Android Module Wizard
Post by: thierrydijoux on October 11, 2014, 09:37:04 pm
@jmpessoa and @Leledumbo :Thanks for your reply

@Leledumbo : how can i have or genrate the R.java JNI wrapper ? I think it's the same thing for all resources (bitmap etc).
Managing translations in the generated .so is not really a problem, but managing bitmap for different screens resolutions can be tricky. I think the R.java JNI wrapper could be quite usefull.

@jmpessoa : have you try to access the android actionbar with fpc ?
Title: Re: Android Module Wizard
Post by: Leledumbo on October 12, 2014, 05:37:14 am
@Leledumbo, you got played with new "form designer" version?  ;D
Is it in the github already?
@Leledumbo : how can i have or genrate the R.java JNI wrapper ? I think it's the same thing for all resources (bitmap etc).
Managing translations in the generated .so is not really a problem, but managing bitmap for different screens resolutions can be tricky. I think the R.java JNI wrapper could be quite usefull.
The same as creating other JNI wrapper. jmpessoa should be able to tell you what to do to create a JNI wrapper in general with his AMW.
Title: Re: Android Module Wizard
Post by: xinyiman on October 12, 2014, 03:10:35 pm
Hello guys, I'm trying to follow this video guide

when I install the package lazandroidwizardpack me this error

C: \ laz4android \ components \ LazAndroidWizard \ androidwizard_intf.pas (166.15) Error: There is no method in an ancestor class to be overridden: "GetObjInspNodeImageIndex (TPersistent; LongInt var);"

I'm on windows xp
How can I fix?

thanks
Title: Re: Android Module Wizard
Post by: greenzyzyzy on October 12, 2014, 05:05:27 pm
Hi  greenzyzyzy, can you try this?

https://jmpessoa.opendrive.com/files?Ml82NTcyMDQ3MV84bEk5bQ

or

https://www.mediafire.com/?cuban3u110gnolb


I'll try to do an GITHUB update later this week ....

The demos is here:

http://www.mediafire.com/download/y6w8pie3h1k15ux/demos_eclipse_projects_02_october_2014.rar


Thank you!

ok,downloaded. thank you.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 12, 2014, 06:12:35 pm
Hi xinyiman, please, read this:  ;D


-->> Windows Users: Get LiteZarus4Android [Lazarus 1.3 + x2nie patch [No LCLform design] + TrueTom fpc 2.7.1 cross Arm/x86/android/]



                        ::To Install, please, read the "LiteZarus4Android_readme.txt"

      Download from: [EDITED!]

                https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21236

                        :: right click to download!
         
-->> Linux Users: Get Lazarus 1.3 rev >= 45216,45217 ... and fpc 2.7.1 cross /arm/x86/android ... etc

Thank you!
Title: Re: Android Module Wizard
Post by: xinyiman on October 12, 2014, 07:19:10 pm
Hi xinyiman, please, read this:  ;D


-->> Windows Users: Get LiteZarus4Android [Lazarus 1.3 + x2nie patch [No LCLform design] + TrueTom fpc 2.7.1 cross Arm/x86/android/]

                        ::To Install, please, read the "LiteZarus4Android_readme.txt"

      Download from: [EDITED!]

                https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21236
         
-->> Linux Users: Get Lazarus 1.3 rev >= 45216,45217 ... and fpc 2.7.1 cross /arm/x86/android ... etc

Thank you!

Thank you!  :)
Title: Re: Android Module Wizard
Post by: xinyiman on October 12, 2014, 09:21:34 pm
A curiosity, if I have a project already created how can I bring up the configuration wizard for android?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 12, 2014, 10:03:17 pm
@xinyiman, sorry, I do Not understand! :-\

An old Eclipse project?

An old Eclipse project + LazWizardModule project?
Title: Re: Android Module Wizard
Post by: xinyiman on October 13, 2014, 03:03:22 pm
For example, if I want to change the setting of '"Android Module Wizard" to one of the examples that you make available to learn. How can I do?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 13, 2014, 07:17:13 pm
Hi xinyiman,

The example projects do not depends of the "Android Module Wizard" configuration [paths etc..]... if you install is ok, then just open the lazarus project in "\jni" folder ["controls.lpi"] .... now you can modify it!

To produce new modified android Apk

1. Just use eclipse to import the example project .... after do  "->refresh"  and "->run" it!

2. Or just use java "ant"  utility.....

Thank you!

Title: Re: Android Module Wizard
Post by: xinyiman on October 14, 2014, 12:48:21 pm
ok, but when I go to "Build" tells me that there is no output folder

C:\adt32\eclipse\workspace\AppSqliteDemo1\jni

Where do I go to change the destination folder?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 14, 2014, 07:53:17 pm
Hi  xinyiman,

1. Is you using eclipse?

2. You imported the project to eclipse?

3. If  (1 and 2) = yes, then open the lazarus project and "save all" to the new \jni path....

4. Go to Lazarus IDE

->Project

->Project -> Option

->Path

Change this information for correct one!

"C:\adt32\ndk7"

"C:\adt32\eclipse\workspace"

Thank You!

PS.

 
Quote
"C:\adt32\eclipse\workspace"
Is my "eclipse workspace" with I have set in  Android Module Wizard  config path dialog....
 
Quote
"C:\adt32\ndk7"
Is my "NDK" path with I have set in  Android Module Wizard  config path dialog....

What is your eclipse workspace path...?
What is your NDK path...?



Title: Re: Android Module Wizard
Post by: xinyiman on October 15, 2014, 03:03:59 pm
Ok change, but other error. Why?


Error: Path "C:\adt32\eclipse\workspace\AppSqliteDemo1\libs\armeabi\" does not exist
Title: Re: Android Module Wizard
Post by: Leledumbo on October 15, 2014, 03:08:13 pm
Ok change, but other error. Why?


Error: Path "C:\adt32\eclipse\workspace\AppSqliteDemo1\libs\armeabi\" does not exist
Adjust those paths to YOUR installation.
Title: Re: Android Module Wizard
Post by: xinyiman on October 15, 2014, 03:09:39 pm
where?
Title: Re: Android Module Wizard
Post by: Leledumbo on October 15, 2014, 03:34:29 pm
where?
I don't know, it's your computer, not mine. You should know by yourself despite the hardcoded paths in the examples.
Title: Re: Android Module Wizard
Post by: xinyiman on October 15, 2014, 03:49:43 pm
But I have changed the paths That I have said jmpessoa but WHEN do you build tells me this.
Title: Re: Android Module Wizard
Post by: BigChimp on October 15, 2014, 04:19:54 pm
May be a good idea to indicate where you changed what exactly.
Title: Re: Android Module Wizard
Post by: xinyiman on October 15, 2014, 04:36:08 pm
Io ho cambiato le mie impostazioni in questi posti

Hi  xinyiman,

Lazarus

->Project

->Project -> Option

->Path

Change this information for correct one!

"C:\adt32\ndk7"

"C:\adt32\eclipse\workspace"

Title: Re: Android Module Wizard
Post by: jmpessoa on October 15, 2014, 05:35:04 pm
Hi xinyiman

Quote
Error: Path "C:\adt32\eclipse\workspace\AppSqliteDemo1\libs\armeabi\" does not exist

Open/edit the "controls.lpi" [...\jni],  you can use Notepad like editor....

Modify some [piece] of path information [C:\adt32\eclipse\workspace] according to your system ..
Title: Re: Android Module Wizard
Post by: xinyiman on October 16, 2014, 03:35:11 pm
Hi xinyiman

Quote
Error: Path "C:\adt32\eclipse\workspace\AppSqliteDemo1\libs\armeabi\" does not exist

Open/edit the "controls.lpi" [...\jni],  you can use Notepad like editor....

Modify some [piece] of path information [C:\adt32\eclipse\workspace] according to your system ..

It's ok! :)

But when I install the package on my android (2.3.6) phone I get this message

"problem with the analysis of the packet"

why?!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 16, 2014, 09:39:29 pm
Hi All!

There is a  MAJOR Android Module Wizard update!

Please, ref: https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - 15 October 2014 -
   1. NEW !!
      -->> Android Widgets Fom Designer! //<<--- thanks to LiteZarus by x2nie!
                      form1 design : https://jmpessoa.opendrive.com/files?Ml82NTQ0NDMxNl9CV292dg
                      form1 Screen : https://jmpessoa.opendrive.com/files?Ml82NTQ0NDM2OV9SUVJ1NA
                      form2 design : https://jmpessoa.opendrive.com/files?Ml82NTQ0Nzk5N19RbXFjVw
                      form2 Screen : https://jmpessoa.opendrive.com/files?Ml82NTQ0NzQ3NF9wMGhHcQ

      -->> Windows Users: Get LiteZarus4Android
         [Lazarus 1.3 + x2nie patch [No LCLform design] +
         TrueTom fpc 2.7.1 cross Arm/x86/android/]

         :DOWNLOAD from: https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21236 [right click to download!]
         :To Install, please, read the "LiteZarus4Android_readme.txt"

         1. From LiteZarus4Android IDE - Install Wizard Packages
         1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk"  [Android Components Bridges!]
            Ref. image: https://www.opendrive.com/files?Ml8zNjMwNDQ3NF83SzhsZg
         1.1.1 From Package Wizard
            - Compile
            - Use -> Install
          1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
            1.2.1 From Package Wizard
            - Compile
            - Use -> Install     
         HINT: to compile/install/reinstall a package in LiteZarus4Android,
            please, open a "dummy" windows project....
            you always MUST close the cross compile project!           

      -->> Linux Users: Get Lazarus 1.3 rev >= 45216,45217 ... and fpc 2.7.1 cross /arm/x86/android ... etc.

   2. NEW !!
      -->> AppTest1 [eclipse project] :: jPanel and form close/callback demo...
      -->> AppTest2 [eclipse project]::Present direct/hack JNI access and a new component implementation
                  model "laz_and_jni_controls.pas" [not java wrapper at all!]
                  [--->> A suggestion and request by Stephano]                   
      -->> All Apps Demos [Eclipse projects] was adjusted/updated ! 
      -->> All project now support Ant "build.*" "intall.*" etc..
         :warning: if needed change this files according to your system!

   3. Guide line for "Old" Projects [Collateral Effects]
      -->> Some TAndroidModule Form properties was supressed!
                -->> Some jComponents properties was supressed!
         Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading" !
      -->> Components conteiners behavior [jPanel e jScrollView] :  remove and put [again] yours controls into them!                 
      -->> Now adjust yours widgets, the concept continue the same:
         .LayoutParamWidth/LayoutParamHeight
         .Anchor
         .PosRelativeToAnchor
         .PosRelativeToParent
         WARNING: android's "wildcards" [WrapContent and lpMatchParent] overlaps the design vision!
               and more: if this properties values are achieved, the "Object Inspector" will "freeze"
               this value! To "unfreeze" not just change by design, you will need
               change the value in OI by hand to any other value, so it will adjust correctly!
      -->> Add new "AndroidWidget" unit to uses clauses [*.dpr/*.pas]

   4. How to use the Demos:
      Change this information to correct one!
         "C:\adt32\ndk7"   -- just my system NDK path
         "C:\adt32\eclipse\workspace"  -- just my system eclipse workspace
      1. Go to Lazarus IDE
         ->Project
         ->Project -> Option
         ->Path
         change/modify paths according to your system ..
      2. Open/edit the "controls.lpi" [...\jni],  you can use Notepad like editor....
         Modify some [piece] of path information
         [C:\adt32\eclipse\workspace]
         [C:\adt32\ndk7]
         according to your system ..

           3. For Ant users: Change/edit build.* , intall.* , unistall.*, logcat.*  according to your system!
                                  
   5.FIXs [BUGS]   
      -->> The form *.lfm parse now is OK !!!
      -->> jListView bug fix[check/not checkd]
         and new added properties: "HighLightSelectedItem" [True/False] and "HighLightSelectedItemColor"

Thanks to All!
Title: Re: Android Module Wizard
Post by: chenyuchih on October 17, 2014, 01:45:54 am
OH MY GOODNESS! Nice Job!
Thanks for your hard works for this!
Title: Re: Android Module Wizard
Post by: Leledumbo on October 17, 2014, 05:22:07 am
Seems like the form designer is in github already. I'm pulling...
Title: Re: Android Module Wizard
Post by: jmpessoa on October 17, 2014, 08:48:19 pm
Hi!

1. Fix a minor bug in "controls.dpr" generated code: commented the "datetime" in the "first" line!   [thanks to Stephano!]
2. The AppAntDemo1 was updated! [thanks to Stephano!]

Thanks to All!
Title: Re: Android Module Wizard
Post by: xinyiman on October 18, 2014, 09:56:11 pm
According to me you could create a virtual machine that has as its sole purpose is to create Android applications with this tool. It would be good to do it in linux (any version). Because the end user to program interesting and not realize the development environment. What do you say, someone wants to do it? But then to be kept up to date. I guarantee that many would use it.
Title: Re: Android Module Wizard
Post by: Fred vS on October 18, 2014, 11:31:07 pm
Hello  ;)

Are you using/testing Android on VirtualBox ?

I have install android-x86-4.4-RC1.iso on VirtualBox-linux-Mint/64bit, it works sometimes but it has lot of crash too.  :-X

Do you have a better iso ?

Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 19, 2014, 03:12:07 am
@xinyiman,
@Fred vS

I do not use virtual machine/box.... I have not thought about this possibility or necessity...

1. To make android App:

-----On windows you can try:

LiteZarus4Android [Lazarus 1.3 + x2nie patch [No LCLform design] + TrueTom fpc 2.7.1 cross Arm/x86/android/]

:DOWNLOAD from: https://onedrive.live.com/redir?resid=78D6F726E8F0C522%21236 [right click to download!]

:To Install, please, read the "LiteZarus4Android_readme.txt"

----On Linux: get Lazarus 1.3 rev >= 45216,45217 ... and fpc 2.7.1 cross /arm/x86/android ... etc.

2. To Run/Test App:

-->> Emulator
-->> Real Device [my is Galaxy S3 / android 4.3]

Greetings!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on October 19, 2014, 03:47:22 am
Hello guys, I'm trying to follow this video guide

when I install the package lazandroidwizardpack me this error

C: \ laz4android \ components \ LazAndroidWizard \ androidwizard_intf.pas (166.15) Error: There is no method in an ancestor class to be overridden: "GetObjInspNodeImageIndex (TPersistent; LongInt var);"

I'm on windows xp
How can I fix?

thanks

i got the same problem,if i do not want to use LiteZarus4Android,can i mark this codes  out?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 19, 2014, 05:11:48 am
Well, you just need Lazarus 1.3 rev >= 45216,45217

But,  LiteZarus4Android [win32]  is a cross compile package!

     = Lazarus 1.3 rev >= 45216,45217  +
        TrueTom fpc 2.7.1 cross Arm/x86/android/  [for NDK 9b]

Greetings!

PS. Precisely the  [@x2nie] patch is a contribution to No LCLform design ["GetObjInspNodeImageIndex" ... etc ]!

Title: Re: Android Module Wizard
Post by: truetom on October 19, 2014, 07:20:06 am
Hello all,

I have updated laz4android to new version.

Date:2014-10-18
FPC: 2.7.1 SVN 28863  win32/arm-android/i386-android/jvm-android
Lazarus:1.3 trunk svn 46592
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

2014-10-18:
1.Fixed examples\androidlcl,now it can compatible with this version.

2.Compatible with Jmpessoa's LazAndroidModuleWizard,thanks Jmpessoa and Simonsays.

the Link:
http://sourceforge.net/projects/laz4android/files/?source=navbar (http://sourceforge.net/projects/laz4android/files/?source=navbar)

Thanks and best regards!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 19, 2014, 01:44:26 pm
Hi TrueTom!

I Will add support [Android Module Wizard] for this new release!

I will try it today!

Thank you again!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 20, 2014, 04:48:33 am
Hi!

I have updated [github] Android Module Wizard!

NEW! Added support to the new [TrueTom] Laz4android

Quote
Lazarus:1.3 trunk svn 46592 +
FPC: 2.7.1 SVN 28863  win32/arm-android/i386-android/jvm-android
Android Ndk 10c

http://sourceforge.net/projects/laz4android/files/?source=navbar
 

Thanks!
Title: Re: Android Module Wizard
Post by: Leledumbo on October 20, 2014, 07:58:03 am
Clicking OK in the wizard (after filling required fields) terminates IDE instantly. Lazarus svn 46619, FPC svn 28884. I'll try to get a proper backtrace.

EDIT:
this is the best I can get:
Code: [Select]
lazarus.pp - unhandled exception
[TMainIDE.Destroy] A
Runtime error 210 at $0000000000425BFC
  $0000000000425BFC
  $00000000004B1778 line 3764 of main.pp
  $00000000004A278F line 1569 of main.pp
  $0000000000516CED
  $00000000004354D0
  $000000000046D0F9 line 39 of qt/interfaces.pp
  $000000000043993]
  $0000000000425BFC
  $00000000008FE888 line 4201 of objectinspector.pp
  $00000000009151D8 line 6250 of propedits.pp
Title: Re: Android Module Wizard
Post by: xinyiman on November 02, 2014, 09:27:39 am
Hello guys I'm doing some tests to start from scratch with a project. And when I create a new project I create the file controls.lpr fact, when I create the package apk and install it on my smart phone will not let me open. Who tells me why?

I used the settings for gingerbread.
Title: Re: Android Module Wizard
Post by: xinyiman on November 02, 2014, 06:12:45 pm
So I'm making progress, I installed everything. I tried to create a blank application and I build the apk file. If I add a button that launches a ShowMessage goes wrong. Download soirce :

www.lazaruspascal.it/download_personali/prova_tel.zip

Who tells me why?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 02, 2014, 07:13:36 pm
Hi  xinyiman,

A strange thing I noticed in your code "Unit1.lfm" :

Code: [Select]
Anchor = jButton1
Try remove this settings [go to Object Inspector and set this property to (none)/blanck]

I think, it can not be anchored himself!

But it can be "anchored" to the parent, example:

set property PosRelativeToParent = [rpCenterInParent]

Thank you!
Title: Re: Android Module Wizard
Post by: xinyiman on November 02, 2014, 08:04:16 pm
I've already tried that ... the apk file I create it but when compiling it says that my source has errors
Title: Re: Android Module Wizard
Post by: jmpessoa on November 02, 2014, 08:13:35 pm
Ok, can you put here the "error message"?
Title: Re: Android Module Wizard
Post by: xinyiman on November 02, 2014, 08:23:26 pm
How do I? There are practical Eclipse
Title: Re: Android Module Wizard
Post by: xinyiman on November 02, 2014, 08:30:45 pm
Description   Resource   Path   Location   Type
Call requires API level 17 (current min is 14): android.widget.EditText#setTextAlignment   Controls.java   /telapp1/src/ft/android/telapp1   line 8840   Android Lint Problem
Call requires API level 17 (current min is 14): android.widget.TextView#setTextAlignment   Controls.java   /telapp1/src/ft/android/telapp1   line 8539   Android Lint Problem
Title: Re: Android Module Wizard
Post by: jmpessoa on November 02, 2014, 09:15:32 pm
Ok,

You're trying to build "Apk" using "ant"  [build.bat] ?

If  true, go to  "build.xml"  and try:

Code: [Select]
<property name="target"  value="android-17"/>
Title: Re: Android Module Wizard
Post by: xinyiman on November 02, 2014, 11:34:15 pm
how build apk using ant?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 02, 2014, 11:53:18 pm
Open  "build.xml"  and change to:  [all in project folder!]

Code: [Select]
<property name="target"  value="android-17"/>

Simply run "build.bat"  --->> build Apk
Simply run "install.bat"  --->> install Apk on device or emulator


Title: Re: Android Module Wizard
Post by: xinyiman on November 03, 2014, 11:41:18 am
result
Code: [Select]
C:\Users\generico\workspace\provaace>build.bat

C:\Users\generico\workspace\provaace>set path=C:\android\ant\bin

C:\Users\generico\workspace\provaace>set JAVA_HOME=C:\Program Files\Java\jdk1.8.
0_25

C:\Users\generico\workspace\provaace>cd C:\Users\generico\workspace\provaace

C:\Users\generico\workspace\provaace>ant -Dtouchtest.enabled=true debug
Buildfile: C:\Users\generico\workspace\provaace\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at C:\android\sdk

-setup:
     [echo] Project Name: provaace
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for provaace...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsObj
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for provaace...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] C:\Users\generico\workspace\provaace\res\values-v11\styles.xml:7: er
ror: Error retrieving parent for item: No resource found that matches the given
name 'Theme.AppCompat.Light'.
     [aapt] C:\Users\generico\workspace\provaace\res\values-v14\styles.xml:8: er
ror: Error retrieving parent for item: No resource found that matches the given
name 'Theme.AppCompat.Light.DarkActionBar'.

BUILD FAILED
C:\android\sdk\tools\ant\build.xml:653: The following error occurred while execu
ting this line:
C:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 5 seconds

C:\Users\generico\workspace\provaace>

Title: Re: Android Module Wizard
Post by: jmpessoa on November 03, 2014, 12:25:05 pm
The gingerbread is the question!

Please,  go to AndroidManifest.xml

change to: [9 or 10?]
Code: [Select]
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17" /> 

Please,  go to  "...\res\values"  folder

change "styles.xml" to:
Code: [Select]
<style name="AppBaseTheme" parent="android:Theme.Light">

Sorry, I do not have a gingerbread device to test it!
Title: Re: Android Module Wizard
Post by: xinyiman on November 03, 2014, 04:34:46 pm
Code: [Select]
C:\Users\generico\workspace\provaace>set path=C:\android\ant\bin

C:\Users\generico\workspace\provaace>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25

C:\Users\generico\workspace\provaace>cd C:\Users\generico\workspace\provaace

C:\Users\generico\workspace\provaace>ant -Dtouchtest.enabled=true debug
Buildfile: C:\Users\generico\workspace\provaace\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at C:\android\sdk

-setup:
     [echo] Project Name: provaace
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for provaace...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsObj
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for provaace...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] C:\Users\generico\workspace\provaace\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
     [aapt] C:\Users\generico\workspace\provaace\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.

BUILD FAILED
C:\android\sdk\tools\ant\build.xml:653: The following error occurred while execu
ting this line:
C:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 6 seconds

C:\Users\generico\workspace\provaace>

Title: Re: Android Module Wizard
Post by: jmpessoa on November 03, 2014, 06:45:40 pm
Code: [Select]
[aapt] C:\Users\generico\workspace\provaace\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
     [aapt] C:\Users\generico\workspace\provaace\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.

You can try a desperate attempt:

Delete the folder ...\values-v11

Delete the folde  ...\values-v14

leave only the default ...\values   !!!!!


Title: Re: Android Module Wizard
Post by: xinyiman on November 03, 2014, 07:00:01 pm
Code: [Select]
C:\Users\generico\workspace\provaace>build.bat

C:\Users\generico\workspace\provaace>set path=C:\android\ant\bin

C:\Users\generico\workspace\provaace>set JAVA_HOME=C:\Program Files\Java\jdk1.8.
0_25

C:\Users\generico\workspace\provaace>cd C:\Users\generico\workspace\provaace

C:\Users\generico\workspace\provaace>ant -Dtouchtest.enabled=true debug
Buildfile: C:\Users\generico\workspace\provaace\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at C:\android\sdk

-setup:
     [echo] Project Name: provaace
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for provaace...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsObj
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for provaace...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] C:\Users\generico\workspace\provaace\res\menu\app.xml:6: error: No r
esource identifier found for attribute 'showAsAction' in package 'ft.android.pro
vaace.provaace'
     [aapt] C:\Users\generico\workspace\provaace\res\menu\app.xml:6: error: Erro
r: No resource found that matches the given name (at 'title' with value '@string
/action_settings').

BUILD FAILED
C:\android\sdk\tools\ant\build.xml:653: The following error occurred while execu
ting this line:
C:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 10 seconds

Title: Re: Android Module Wizard
Post by: jmpessoa on November 03, 2014, 08:06:56 pm
Hi xinyiman,

I tried to mimic their project and everything went as expected: build [.so], build apk, install apk and run it!

You can use this link to compare and perhaps you will discover what you're doing....

https://jmpessoa.opendrive.com/files?Ml82NzA2NDQ2NV9QSEFGZA
Title: Re: Android Module Wizard
Post by: xinyiman on November 04, 2014, 08:06:02 am
Then I edited the file by copying it from your menu.xml, but now he says this
Code: [Select]

C:\Users\generico\workspace\provaace>build.bat

C:\Users\generico\workspace\provaace>set path=C:\android\ant\bin

C:\Users\generico\workspace\provaace>set JAVA_HOME=C:\Program Files\Java\jdk1.8.
0_25

C:\Users\generico\workspace\provaace>cd C:\Users\generico\workspace\provaace

C:\Users\generico\workspace\provaace>ant -Dtouchtest.enabled=true debug
Buildfile: C:\Users\generico\workspace\provaace\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at C:\android\sdk

-setup:
     [echo] Project Name: provaace
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for provaace...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsObj
    [mkdir] Created dir: C:\Users\generico\workspace\provaace\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for provaace...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] C:\Users\generico\workspace\provaace\res\menu\app.xml:3: error: Erro
r: No resource found that matches the given name (at 'title' with value '@string
/action_settings').

BUILD FAILED
C:\android\sdk\tools\ant\build.xml:653: The following error occurred while execu
ting this line:
C:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 6 seconds


in particular do not understand this
Code: [Select]
C:\Users\generico\workspace\provaace\res\menu\app.xml:3: error: Erro
r: No resource found that matches the given name (at 'title' with value '@string
/action_settings').

the xml file is as follows
Code: [Select]
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>

</menu>

Title: Re: Android Module Wizard
Post by: xinyiman on November 04, 2014, 08:58:48 am
I solved the problem by copying the folder / res of your project in my project. And it worked. Of course I went to change his name of the XML file appropriately.

Thank youuuuuuu
Title: Re: Android Module Wizard
Post by: xinyiman on November 04, 2014, 12:00:36 pm
I have a problem when drawing components on androidmodule the following properties do not change based on where I move the component. In someone else happen?

The properties are:

MarginBottom, MarginLeft, MarginRight, MarginTop
Title: Re: Android Module Wizard
Post by: jmpessoa on November 04, 2014, 12:19:51 pm
Yes, this properties has this limitation in  drawing,  maybe I'll still make this better ...

But their values ​​are considered in run time!

Edited: a remark, this properties manages the inside component space (pad) not the localization concerning to the form!
Title: Re: Android Module Wizard
Post by: xinyiman on November 05, 2014, 10:02:25 am
So in practicing with this wonderful tool I was able to create a database, a table, insert 4 records ... but when I try to view the records I go wrong. Here you will find the project: www.lazaruspascal.it/download_personali/provaace.zip

Who tells me where am I wrong?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 06, 2014, 12:25:48 pm
Hi  xinyiman,

You can do:

Code: [Select]
  ShowMessage(IntToStr(rows.Count)) ;

Is the correct count?
 
Title: Re: Android Module Wizard
Post by: xinyiman on November 12, 2014, 09:34:32 am

I tried to do as you say, but it continues to go wrong. Ideas?

Code: [Select]
procedure TAndroidModule1.jButton2Click(Sender: TObject);
var
  rows: TStringList;
  i: integer;
begin


          try
             try
                rows:= TStringList.Create;
                rows.StrictDelimiter:= True;
                rows.Delimiter:= jSqliteDataAccess1.RowDelimiter;
                rows.DelimitedText:= jSqliteDataAccess1.Select('SELECT * FROM '+  FTableName);
                {for i:= 0 to rows.Count-1 do
                begin
                  ShowMessage(rows.Strings[i]);
                end;}
                ShowMessage(IntToStr(rows.count));
                rows.Free;

             finally
                    //codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione
            end;
          except
                on E: Exception do
                begin

                   //codice da eseguire solo se si verifica un eccezzione
                   showmessage(e.Message);
                end;
          end;



end;
Title: Re: Android Module Wizard
Post by: jmpessoa on November 12, 2014, 04:31:24 pm
Quote
...continues to go wrong..

Code: [Select]
              {for i:= 0 to rows.Count-1 do
                begin
                  ShowMessage(rows.Strings[i]);
                end;}

                ShowMessage(IntToStr(rows.count));   // <<-----


Ok, Can say what "count" you got?


Title: Re: Android Module Wizard
Post by: xinyiman on November 12, 2014, 08:39:25 pm
then did more tests ... if this code is not working

FTableName=atleti


Code: [Select]
procedure TAndroidModule1.jButton2Click(Sender: TObject);
var
  rows: TStringList;
  i: integer;
begin
          try
             try
                rows:= TStringList.Create;
                rows.StrictDelimiter:= True;
                rows.Delimiter:=jSqliteDataAccess1.RowDelimiter;
                rows.DelimitedText:=jSqliteDataAccess1.Select('SELECT * FROM '+  FTableName + ';');
                for i:= 0 to rows.Count-1 do
                begin
                  ShowMessage(rows.Strings[i]);
                end;
                rows.Free;
             finally
                    //codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione
            end;
          except
                on E: Exception do
                begin

                   //codice da eseguire solo se si verifica un eccezzione
                   showmessage(e.Message);
                end;
          end;
end;



so does work


Code: [Select]
procedure TAndroidModule1.jButton2Click(Sender: TObject);
var
  rows: TStringList;
  i: integer;
begin
          try
             try
                rows:= TStringList.Create;
                rows.StrictDelimiter:= True;
                rows.Delimiter:=jSqliteDataAccess1.RowDelimiter;
                rows.DelimitedText:='ciao#caio#sempronio#pippo#90';
                for i:= 0 to rows.Count-1 do
                begin
                  ShowMessage(rows.Strings[i]);
                end;
                rows.Free;
             finally
                    //codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione
            end;
          except
                on E: Exception do
                begin

                   //codice da eseguire solo se si verifica un eccezzione
                   showmessage(e.Message);
                end;
          end;
end;

this is the line that creates problems. I do not understand ...

jSqliteDataAccess1.Select('SELECT * FROM '+  FTableName + ';');
Title: Re: Android Module Wizard
Post by: jmpessoa on November 12, 2014, 09:29:46 pm


Code: [Select]
jSqliteDataAccess1.Select('SELECT * FROM '+  FTableName + ';');

Yes,  Try cut out the ";" for both:

jSqliteDataAccess1.Insert

and

jSqliteDataAccess1.Select





Title: Re: Android Module Wizard
Post by: xinyiman on November 12, 2014, 09:51:37 pm
tried, nothing changes. ideas?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 12, 2014, 10:21:24 pm


before

Code: [Select]
    jSqliteDataAccess1.Select('SELECT * FROM '+  FTableName);

try 

Code: [Select]
   rowCount:= jSqliteDataAccess1.Cursor.GetRowCount;
   ShowMessage('rowCount= '+ IntToStr(rowCount));

That is ok?
Title: Re: Android Module Wizard
Post by: xinyiman on November 12, 2014, 10:42:24 pm
rowcount=0
Title: Re: Android Module Wizard
Post by: jmpessoa on November 12, 2014, 10:55:06 pm
So we can think the insert command failed .... why?

 You can try again the Insert without the ";"  terminator?

Edited:

comment this, too:
Code: [Select]
     //jSqliteDataAccess1.DeleteFromTable('delete from ' + FTableName + ';');  // <<-----
Title: Re: Android Module Wizard
Post by: xinyiman on November 13, 2014, 08:03:36 am
No change, no more input. I do not understand why
Title: Re: Android Module Wizard
Post by: jmpessoa on November 14, 2014, 08:58:28 am
Hi  xinyiman, you can try use "AppSqliteDemo1" as is? Well,  you need modify some Project settings [paths]...

But I wil continue trying to find why your code fails ..
Title: Re: Android Module Wizard
Post by: jmpessoa on November 14, 2014, 09:02:21 am
Hi All! There are a  update [revision] for Android Module Wizard...

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 05 - 13 November 2014 -

   NEW! Lazarus Package "amw_ide_tools.lpk" (*) [..\LazAndroidWizard\ide_tools]

      .Add entry "Android Module Wizard" to Lazarus IDE "Tools" menu <<--- by Thierry Dijoux!
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzAyNF9leGVIVg

      .Add sub entry "Late: Apk Expert Tools [Build, Install, ...]" <<---- by Thierry Dijoux!
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA2N184VWZaWg

         :: Improves and automates the "Ant" support!

      .Add sub entry "Upgrade Code Templates [*.lpr, *.java]"
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA3Ml80MFVjSQ

         :: Yes, Now became easy to keep the [olds] projects in sync with the new AMW version-revision!   

      .Add sub entry "Path Settings [JDK, SDK, NDK, ...]" <<--- Stephano's sugestion! (**)
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA1OF9yVVU3RA

         :: WARNING: I recommend that "new" User start here: Set Paths to JDK, SDK, NDK, ...
      
      (*)Please, look for [and install it!] "amw_ide_tools.lpk" in folder ..\LazAndroidWizard\ide_tools

      (**) Yes, this paths configuration was removed from prompt dialog of "Android Module Wizard"
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzE0Nl9LczBuTQ
      
      WARNING! Windows Users: Please, update to [new] TrueTom Laz4Android [or some more advanced!]
       ref. http://sourceforge.net/projects/laz4android/files/?source=navbar
      :To Install, please, read the "Laz4Android_readme.txt"

   NEW!   .jShareFile component [Android Bridges Extra]
      .jImageFileManager component [Android Bridges Extra]

      .Add new methods to jForm:
                           
         CopyFile;
         DeleteFile;
         CreateDir;
         LoadFromAssets; //<-- result the full path to app internal storage
         
         GetEnvironmentDirectoryPath;
         GetInternalAppStoragePath;
                     
         IsSdCardMounted;                        
         IsExternalStorageEmulated;
         IsExternalStorageRemovable;

         IsWifiEnabled;
         SetWifiEnabled;

   NEW! DEMO AppShareFileDemo1 [Eclipse Project]
      -->> jShareFile, jTexFileManager and jImageFileManager
                                                                           
   FIX! Improves/fix the support to Project Compiler Options ... Thanks to Stephano!

Thanks to All!
Title: Re: Android Module Wizard
Post by: Leledumbo on November 15, 2014, 05:31:05 pm
Hi All! There are a  update [revision] for Android Module Wizard...

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 05 - 13 November 2014 -

   NEW! Lazarus Package "amw_ide_tools.lpk" (*) [..\LazAndroidWizard\ide_tools]

      .Add entry "Android Module Wizard" to Lazarus IDE "Tools" menu <<--- by Thierry Dijoux!
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzAyNF9leGVIVg

      .Add sub entry "Late: Apk Expert Tools [Build, Install, ...]" <<---- by Thierry Dijoux!
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA2N184VWZaWg

         :: Improves and automates the "Ant" support!

      .Add sub entry "Upgrade Code Templates [*.lpr, *.java]"
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA3Ml80MFVjSQ

         :: Yes, Now became easy to keep the [olds] projects in sync with the new AMW version-revision!   

      .Add sub entry "Path Settings [JDK, SDK, NDK, ...]" <<--- Stephano's sugestion! (**)
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA1OF9yVVU3RA

         :: WARNING: I recommend that "new" User start here: Set Paths to JDK, SDK, NDK, ...
      
      (*)Please, look for [and install it!] "amw_ide_tools.lpk" in folder ..\LazAndroidWizard\ide_tools

      (**) Yes, this paths configuration was removed from prompt dialog of "Android Module Wizard"
      ref. image: https://jmpessoa.opendrive.com/files?Ml82Nzg4MzE0Nl9LczBuTQ
      
      WARNING! Windows Users: Please, update to [new] TrueTom Laz4Android [or some more advanced!]
       ref. http://sourceforge.net/projects/laz4android/files/?source=navbar
      :To Install, please, read the "Laz4Android_readme.txt"

   NEW!   .jShareFile component [Android Bridges Extra]
      .jImageFileManager component [Android Bridges Extra]

      .Add new methods to jForm:
                           
         CopyFile;
         DeleteFile;
         CreateDir;
         LoadFromAssets; //<-- result the full path to app internal storage
         
         GetEnvironmentDirectoryPath;
         GetInternalAppStoragePath;
                     
         IsSdCardMounted;                        
         IsExternalStorageEmulated;
         IsExternalStorageRemovable;

         IsWifiEnabled;
         SetWifiEnabled;

   NEW! DEMO AppShareFileDemo1 [Eclipse Project]
      -->> jShareFile, jTexFileManager and jImageFileManager
                                                                           
   FIX! Improves/fix the support to Project Compiler Options ... Thanks to Stephano!

Thanks to All!
A lot of changes needed to readme.md (it's the one displayed on the github front page). It's going to take some time for me applying the diff.
Title: Re: Android Module Wizard
Post by: zariq on November 15, 2014, 10:22:51 pm
jsharefile_icon.lrs missing.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 16, 2014, 12:21:00 am
Thank you Zariq!

Now I fixed it!
Title: Re: Android Module Wizard
Post by: jmpessoa on November 16, 2014, 03:16:56 am
Hi All,

      .[About using] "Late: Apk Expert Tools [Build, Install, ...]" <<---- by Thierry Dijoux!

         :[Building Android Apk]  If you got [freezing]:

                               "[echo] Resolving Build Target for...":

            ref image https://jmpessoa.opendrive.com/files?Ml82Nzk0NzM1N19taU1QUg

            .Please, Open ["build.xml"] {notepad like editor...}

            .Change this line:
Code: [Select]
"<property name="target"  value="android-14"/>"
               to another [target] supported by your SDK installation. [ex: "android-17"]

Code: [Select]
"<property name="target"  value="android-17"/>"                

Thanks to All!
Title: Re: Android Module Wizard
Post by: truetom on November 17, 2014, 01:33:42 pm
Great job!Thank you jmpessoa!

I am testing it ,but looks lost a Property "ForceStop" in the ide_tools\threadprocess.pas ,

    property ForceStop: boolean read FForceStop write FForceStop;

Thanks and best regard!
 

Title: Re: Android Module Wizard
Post by: xinyiman on November 17, 2014, 04:33:53 pm
Ok, i installed new version and into amw_ide_tools.lpk installation i have this errors:

Compilazione del pacchetto amw_ide_tools 0.0: Codice di uscita 1, Errori: 1, avvertimenti: 1, suggerimenti: 1
uformsettingspaths.pas(51,46) Hint: Parameter "CloseAction" not used
threadprocess.pas(69,16) Warning: Symbol "CommandLine" is deprecated
lazandroidtoolsexpert.pas(563,18) Error: identifier idents no member "ForceStop"
Title: Re: Android Module Wizard
Post by: jmpessoa on November 17, 2014, 04:56:42 pm
Thanks to all!

I fixed lazandroidtoolsexpert.pas: no more ForceStop!
Title: Re: Android Module Wizard
Post by: xinyiman on November 17, 2014, 06:00:49 pm
news to my problem?
Title: Re: Android Module Wizard
Post by: xinyiman on November 23, 2014, 08:11:40 am
So I modified the design to make it fill AppSqliteDemo1 from my pc. I get the .apk file and when I go to install it on my samsung galaxy ace says:

"parsing error
problem with the analysis of the package"

This is the link to where you find the project with the changes made by me in different path.

www.lazaruspascal.it/download_personali/AppSqliteDemo1.zip

You tell me what's wrong? Also for gingerbread. thanks
Title: Re: Android Module Wizard
Post by: Leledumbo on November 23, 2014, 03:31:09 pm
I updated the workspace dialog to use anchors & autosizing so it looks good on all platforms. Please check though, I only have Linux. Currently, there's still crash after flling the dialog, after asking for Laz4Android location (I don't think it's required). I'm still investigating.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 23, 2014, 05:09:28 pm
@ Leledumbo,

Quote
...after asking for Laz4Android location (I don't think it's required)...

Yes, we need "lazbuild" to rebuild ".so" in "LATE" [IDE plugin]...

Thank you!

EDITED:

1. @xinyiman: I will test it!

2.Roadmap: I'm finishing support to ActionBar! and a complete redesign of jMenu component (and NEW jContextMenu) with total support to it and Icons!
Title: Re: Android Module Wizard
Post by: Leledumbo on November 24, 2014, 02:12:12 am
@ Leledumbo,

Quote
...after asking for Laz4Android location (I don't think it's required)...

Yes, we need "lazbuild" to rebuild ".so" in "LATE" [IDE plugin]...
lazbuild is part of lazarus, not laz4android, so it should be deducible automatically.
Title: Re: Android Module Wizard
Post by: Leledumbo on November 26, 2014, 08:41:58 am
Finally, it works with Lazarus trunk on Linux. I can create a project, but somehow I can't drop any component on the module. Any component on any palette will redirect me to standard tab with no component selected. Existing projects, such as the demos, can be opened and I can see the form designer with components rendered fine. Same problem with dropping new components, though.

Weird thing is that I can drop components from android bridge tab to lcl form, but not on android module. Maybe I should try on stable lazarus.

EDIT:
It's a regression (http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Cannot-add-components-to-FPWebModule-anymore-td4039554.html).
Title: Re: Android Module Wizard
Post by: jmpessoa on December 03, 2014, 07:32:09 am
Hi All

There is a new update to Android Module Wizard!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 06 - 03 December 2014 -
      
   NEW!
      .Add sub entry "Resource Editor" ["Android Module Wizard" to Lazarus IDE "Tools" menu] <<---- by Thierry Dijoux
      .LATE [IDE Tools]: Improve logcat support:
         --> TAG Filter log
         --> Run Time Error log
      
   NEW!   .jContextMenu component [Android Bridges Extra]  -->> Improve the support to Android Menus....
      .jMenu - Improve support --> Icons and ActionBar support!

         UPDATE Demo: AppMenuDemo
         ref. images:
            https://jmpessoa.opendrive.com/files?Ml82OTk0MjAzNV9VekM1dA
            https://jmpessoa.opendrive.com/files?Ml82OTk0MjE2MF9QS1dTaQ
            https://jmpessoa.opendrive.com/files?Ml82OTk0MjI2OF9jU3ZwSg

      .jActionBarTab component [Android Bridges Extra] - ActionBar TAB Support!

         NEW! Demo: AppActionBarTabDemo1 -
         ref. Images:            
                                https://jmpessoa.opendrive.com/files?Ml82OTk0MjM4OV9jRklmaw
            https://jmpessoa.opendrive.com/files?Ml82OTk0MjQ3Ml96N1ZTMg
            https://jmpessoa.opendrive.com/files?Ml82OTk0MjU5MF82VlRrNA

      .Add new methods to jForm  [ActionBar Support!]:
      
         GetActionBar;   
         HideActionBar;
         ShowActionBar;
         ShowTitleActionBar;
         HideLogoActionBar;
         SetTitleActionBar;
         SetSubTitleActionBar;
         SetIconActionBar;
         RemoveAllTabsActionBar();

         SetTabNavigationModeActionBar;  --- Need for ActionBar TAB Support!


      WARNING: Action bar was introduced in Android 3.0 (API level 11)
      [Set targetSdkVersion to >= 14, then test your app on Android 4.0]


      .Others improvements and fixs by Leledumbo!

Thanks to All!
Title: Re: Android Module Wizard
Post by: jmpessoa on December 07, 2014, 05:54:07 am
Hi All

There is a new update to Android Module Wizard!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 07 - 07 December 2014 -

   NEW!   .jCustomDialog component [Android Bridges Extra]  <<---- A suggestion and request by Leledumbo

         NEW! Demo: AppCustomDialogDemo1
         ref. image:
            https://jmpessoa.opendrive.com/files?Ml83MDgwNTQxMl9jTEJkcA

Thanks to All!

Title: Re: Android Module Wizard
Post by: jmpessoa on December 16, 2014, 06:09:23 pm
Hi All

I have updated  "Android Module Wizard"

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 08 - 15 December 2014 -

   NEW! Add Support to build release Apk!
      [win  -->> build-release.bat]
      [linux ->> build-release.sh]

      Please, look for:
         readme.txt [Project Folder]
         readme-keytool-input.txt [Project Folder]

   IMPROVEMENTS:

   Component "jSqliteDataAccess" [.pas]
      
      News Methods:

         SetForeignKeyConstraintsEnabled;
         SetDefaultLocale;

         DeleteDatabase;          
         CheckDataBaseExistsByName

         InsertIntoTableBatch
         UpdateTableBatch   
         UpdateImageBatch

   Class "jSqliteDataAccess" [java wrapper]

   Added Safe operation:

       beginTransaction();
         ....
      setTransactionSuccessful()
         ....
      endTransaction();

   NEW!   App Demo: AppSqliteDemo2

   FIXs   Some minor fixs!
Title: Re: Android Module Wizard
Post by: jmpessoa on December 20, 2014, 06:59:05 am
Hi All

There is a updated revision of  "Android Module Wizard"

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 09 - 20 December 2014 -

   NEW! Improve/Add support to res/drawable to [many] components:
               .jBitmap
               .jImageView
               .jImageBtn
               .jListView
               .jImageFileManager
       And Fixs...
Title: Re: Android Module Wizard
Post by: Leledumbo on December 20, 2014, 07:43:10 am
Hello, jmpessoa. As more features are added, lazandroidmodule becomes bigger and bigger. Even hello, world now eats nearly 1 MB apk (with .so itself eats 2.6 MB uncompressed). Do you think it's the time to refactor the code so only needed ones get linked in?
Title: Re: Android Module Wizard
Post by: jmpessoa on December 20, 2014, 06:01:15 pm
@Leledumbo

Quote
...  .so itself eats 2.6 MB uncompressed ...

I agree with you. From Pascal side I can do the this task just now... If you can point out some bottleneck and offer any suggestions will be very well accepted!

Thank You!
Title: Re: Android Module Wizard
Post by: ps on December 21, 2014, 10:46:46 am
Nice work jmpessoa!

Hints:
- please can you include in first post Fast tutorial? (from third page?). Its hard to find how to start.
- maybe fast_tutorial_eclipse_users.txt isn't good naming, when I downloaded zip, I spend half hour searching for install instructions. What about rename it to eg.: install_tutorial_eclipse_users.txt (install* is important )
Title: Re: Android Module Wizard
Post by: jmpessoa on December 21, 2014, 06:58:04 pm
@Ps

His suggestion was accepted!

   "install_tutorial_ant_users.txt"
   "install_tutorial_eclipse_users.txt"

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on December 22, 2014, 02:12:29 am
Hi All!

There is a updated revision of  "Android Module Wizard"

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 10 - 21 December 2014 -

   Important Code Reorganization: A sugestion by Leledumbo [Thank you very much Leledumbo!]

   Significantly reducing the final size of "controls.so"  [just about half!]

   Typical example:
Code: [Select]
TAndroidModule1 = class(jForm)
jButton1: jButton;
jEditText1: jEditText;
jListView1: jListView;
jSpinner1: jSpinner;
jTextView1: jTextView;
      procedure jButton1Click(Sender: TObject);
private
      {private declarations}
public
      {public declarations}
end;

   Before:
      controls.so  --------- 2768 KB

   After code reorganization:
      controls.so ---------- 1371 KB

Thanks to All!
Title: Re: Android Module Wizard
Post by: Leledumbo on December 22, 2014, 05:55:35 am
Great job, jmpessoa! I haven't even got the time to look at what to do, but you already strip it down to half in size!
Title: Re: Android Module Wizard
Post by: jmpessoa on January 06, 2015, 12:33:35 pm
Hi there!

There is a updated revision of  "Android Module Wizard"

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 11 - 03 January 2015 -

   .Major Code Reorganization/Cleanup [Pascal and Java sides]:
   
   .WARNIG! you need [must] upgrade your existing code/application!
      Please, use the IDE "tools" -> "Android Module Wizard" -> "Upgrade Code Templates"

   .Reducing the final size of "controls.so"  [now less than half!!]
      
   Typical example:
Code: [Select]
TAndroidModule1 = class(jForm)
jButton1: jButton;
jEditText1: jEditText;
jListView1: jListView;
jSpinner1: jSpinner;
jTextView1: jTextView;
      procedure jButton1Click(Sender: TObject);
private
      {private declarations}
public
      {public declarations}
end;
..............................
   Before [Typical example]:
      controls.so  --------- 2768 KB

   After first code reorganization [Typical example]:
      controls.so ---------- 1371 KB

   Now [Typical example]:
      controls.so ---------- 1206 KB  [!!]

   How it scale? The "AppDemo1" uses 14 forms and many, many components and code:
      controls.so ---------- 1379 KB  [Added only 14% !!]

   FIX/NEW! jEditText
      :: New! Added event property "OnChanged"         
      :: FIX/NEW! Event handles now is OK with help of the news methods
         "DispatchOnChangeEvent" and "DispatchOnChangedEvent"!
      :: FIX! InputTypeEx property now is ok!

   NEW! Demo AppEditTextDemo1 [Eclipse Project...]        
                               
   WARNIG! jEditText property name "LineMaxLength" changed to the correct "MaxTextLength" !
      .Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"!
      (simulates some component property change e save it!)
   
   WARNIG! jImageView lost the property "IsBackgroundImage"
      .Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"!
      (Simulates some component property change e save it!)
      .Just puts the jImageView "first" on jForm and set LayoutParams [H/W] to lpMatchParent
         (Form Background Image is done!)


Thanks to All!
Title: Re: Android Module Wizard
Post by: jmpessoa on January 11, 2015, 10:44:11 pm
Hi All!

There is a updated revision of  "Android Module Wizard"

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 12 - 10 January 2015 -

   NEW! Added component jToggleButton [Android Bridges Extras]
   NEW! Demo AppToggleButtonDemo1 [Eclipse project]

   NEW! Added component jSwitchButton [Android Bridges Extras]
   NEW! Demo AppSwitchButtonDemo1 [Eclipse project]

   NEW! Added component jGridView [Android Bridges Extras] //<<-A suggestion and request by Valmadson
   NEW! Demo AppGridViewDemo1 [Eclipse project]

   FIXs : Some component lost needless published property "Text"
      .Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"
      (simulates just one component property change e save it!)

   UPDATED! All Demos updated!

Thanks to All!
Title: Re: Android Module Wizard
Post by: osvaldotcf on January 25, 2015, 11:01:55 pm
Gentlemen, anyone could look at this ? The use of Lazarus Android Module Wizard components on Linux, Ubuntu 14.04 64 bit

https://github.com/jmpessoa/lazandroidmodulewizard/issues/1

The steps are correct ?
Title: Re: Android Module Wizard
Post by: xinyiman on January 30, 2015, 09:17:27 pm
Hello guys, I want to prepare a virtual machine (linux) with everything already installed. I want to know the right steps to do

1. Install the Java JDK
2. Install Android-study
3. Install ndk
4. Install Lazarus
5. Install the compiler arm-android (which guide I follow?)

What else?
Title: Re: Android Module Wizard
Post by: Leledumbo on January 31, 2015, 07:07:59 am
Hello guys, I want to prepare a virtual machine (linux) with everything already installed. I want to know the right steps to do

1. Install the Java JDK
2. Install Android-study
3. Install ndk
4. Install Lazarus
5. Install the compiler arm-android (which guide I follow?)

What else?
2 -> Install Android sdk, anything else but the sdk is useless for development with this package
5 -> any guide that can help you create arm-android cross compiler, the Android wiki article should have the pointer
what else -> clone and install the package
Title: Re: Android Module Wizard
Post by: jmpessoa on January 31, 2015, 05:41:41 pm
Hi All!

There is an updated "Lamw" in GitHub: Added support to "core" Android!

ref: https://github.com/jmpessoa/lazandroidmodulewizard

[zip]: https://github.com/jmpessoa/lazandroidmodulewizard/archive/master.zip

Version 0.6 - rev. 13 - 29 January 2015 -

   NEW! Added component jBroadcatReceiver [Android Bridges Extras]
   NEW! Demo AppBroadcatReceiverDemo1 [Eclipse Compatible Project]

   NEW! Added component jSensorManager [Android Bridges Extras]
   NEW! Demo AppSensorManagerDemo1 [Eclipse Compatible Project]
   NEW! Demo AppSensorManagerDemo2[Eclipse Compatible Project]

   NEW! Added component jIntentManager [Android Bridges Extras]
   NEW! Demo AppIntentManagerDemo1 [Eclipse Compatible Project]
   NEW! Demo AppIntentManagerDemo2 [Eclipse Compatible Project]
   NEW! Demo AppIntentManagerDemo3 [Eclipse Compatible Project]

   NEW! New jComponent [Create] Expert
      IDE "tools" -> "Android Module Wizard" -> "New jComponent [Create]"
         Please, read the Tab "Help" ....

   New! Added Options to Select[prebuilt] System = (Windows, Linux-x86, Mac, Linux-x86_64)
      :: A suggestion by @osvaldotcf [Thank you!]

   UPDATED! All Demos updated!

   *****************************************
   * To start:            
   *               
   * "install_tutorial_ant_users.txt"   
   * "install_tutorial_eclipse_users.txt"                                  
   *               *
   *****************************************

Thanks to All!

Ps: "Lamw" remind "lemur" ....  :D :D :D
Title: Re: Android Module Wizard
Post by: xinyiman on February 06, 2015, 09:16:32 pm
Hello, I created a virtual machine with linux installed on top of everything. Now I would like to understand how to create a new project without using eclipse. Can you?
Title: Re: Android Module Wizard
Post by: jmpessoa on February 06, 2015, 11:37:41 pm
Hi xinyiman,

Yes, you can....

Just Select to Ant project!

ref. picture:    https://jmpessoa.opendrive.com/files?Ml83NTc1NzU5Ml9tazVLdg
Title: Re: Android Module Wizard
Post by: ps on February 07, 2015, 07:14:40 pm
Very nice work, but it's realy hard to get working setup. Now I'm done. Here are some hints:
Title: Re: Android Module Wizard
Post by: jmpessoa on February 07, 2015, 08:22:27 pm
Hi Ps,


1.
Code: [Select]
..but it's realy hard to get working setup. ...
Can you help here! What about a new  "Get Start!" tutorial? Help me!

2 and 3.
Code: [Select]
...BackgroundColor is TARGBColorBridge ... why?  :o  I need custom colors..
I do not understand .... any sugestion?

4 and 5. [jHTTPClient, jWebView]

Ok, I'll try to improve its....

Thank you!


Title: Re: Android Module Wizard
Post by: ps on February 08, 2015, 07:32:15 am
Can you help here! What about a new  "Get Start!" tutorial? Help me!
I can look at this.

And for colors, I need do this:
Code: [Select]
jTextView1.BackgroundColor := $FF2C2F3E;
For testing I created code like this and it's working:
Code: [Select]
....
   procedure SetBackColor (Value: DWord);
...
    property BackgroundColor     : TARGBColorBridge read FColor     write SetColor;
    property BackColor: DWord read FBackColor Write SetBackColor;       

...


procedure jTextView.SetBackColor(Value: DWord);
begin
  FBackColor:= Value;
  if (FInitialized = True) and (FBackColor <> $00000000)  then
    View_SetBackGroundColor(FjEnv, FjObject , Value);
end; 

Title: Re: Android Module Wizard
Post by: renabor on February 08, 2015, 10:12:26 am
Here my modified version for installing fpc, lazarus and lazandroidmodulewizardwith on Ubuntu 14.04 64 bit:
-----------------
install some necessary stuff:
sudo apt-get install adb ant fp-compiler openjdk-7-jdk
mkdir ~/Android
cd ~/Android
_Get Android SDK and NDK.
_Create a simbolic link (ln -s) to your sdk/ndk folder (~/Android -> /your/folder/ (ndk and sdk))
_Add to your ~/.bashrc:
export PATH=$PATH:~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin
_Download with svn
svn co http://svn.freepascal.org/svn/lazarus/branches/trunk/
svn co http://svn.freepascal.org/svn/fpc/branches/trunk/
###  ###
(ref.: http://wiki.freepascal.org/How_to_setup_a_FPC_and_Lazarus_Ubuntu_repository)
sudo apt-get install libgtk2.0-dev, libgdk-pixbuf2.0-dev, libgpm-dev, fakeroot, libncurses5-dev, libtinfo-dev

- BUILD FPC.DEB AND FPC-SRC.DEB
ENTER the directory:
cd ~/Android/lazarus/tools/install
EXECUTE:
./create_fpc_deb.sh fpc /home/user/Android/fpc/
REMOVE all fpc deb and fp_ deb (fpc, fpc-src, fp_compiler and so on)
sudo dpkg --remove fpc* fp-*
INSTALL the new fpc package:
sudo dpkg -i ./fpc_3.1.1-150130_amd64.deb
CREATE fpc-src:
./create_fpc_deb.sh fpc-src //home/user/Android/fpc/
INSTALL fpc_src:
sudo dpkg -i fpc-src_3.1.1-150130_amd64.deb

- BUILD LAZARUS.DEB
./create_lazarus_deb.sh append-revision
REMOVE all lazarus deb
sudo dpkg --remove lazarus* lcl-* lcl
INSTALL the new lazarus package:
sudo dpkg -i lazarus_1.5.47565-0_amd64.deb

### ###
- BUILD THE CROSS COMPILER
make clean crossall OS_TARGET=android CPU_TARGET=arm
sudo make crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr
_create simbolic link:
cd /usr/bin
sudo ln -s /usr/lib/fpc/3.1.1/ppcrossarm .
sudo ln -s /usr/bin/ppcrossarm ppcarm
sudo ln -s ~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
sudo ln -s ~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd /usr/bin/arm-linux-androideabi-ld
ln -s /usr/bin/arm-linux-androideabi-as /usr/bin/arm-linux-as
ln -s /usr/bin/arm-linux-androideabi-ld /usr/bin/arm-linux-ld
########## compile dummylibs
cd ~/Android/lazandroidmodulewizard/linux/dummylibs
ln -s /home/renabor/Android/lazandroidmodulewizard/linux/dummylibs/libglesv1_cm.so libGLESv1_CM.so
ln -s /home/renabor/Android/lazandroidmodulewizard/linux/dummylibs/libglesv2.so libGLESv2.so

_Add lines below to /etc/fpc.cfg
#IFDEF ANDROID
#IFDEF CPUARM
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
#ENDIF


Now follow the instructions in: install_tutorial_ant_users.txt
                        1. From Lazarus IDE - Install Wizard Packages

                        1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk"  [Android Components Bridges!]
                                Ref. image: https://www.opendrive.com/files?Ml8zNjMwNDQ3NF83SzhsZg

                        1.1.1 From Package Wizard
                                - Compile
                                - Use -> Install
                        1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
                        1.2.1 From Package Wizard
                                - Compile
                                - Use -> Install

                        1.3 Package -> Open Package -> "amw_ide_tools.lpk"  [folder: ..\LazAndroidWizard\ide_tools]
                        1.3.1 From Package Wizard
                                - Compile
                                - Use -> Install
                                ref. https://jmpessoa.opendrive.com/files?Ml82Nzg4MzAyNF9leGVIVg

        1. From Lazarus IDE menu Tools -->> "Android Module Wizard" --> Paths Settings"

                ref. https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA1OF9yVVU3RA

                -Path to Java JDK

                  ex. /usr/lib/jvm/java-7-openjdk-amd64

                -Path to Android SDK

                  ex. /home/renabor/Android/Sdk

                -Select Ndk version: [10]

                -Path to Ndk

                  ex.  /home/renabor/Android/android-ndk-r10d

                -Path to Java Resources  [Simonsayz's Controls.java,  *.xml and default Icons]:

                  ex. /home/renabor/Android/lazandroidmodulewizard/java

                -Path to Lazbuild

                  ex. /usr/bin


- BUILD YOUR FIRST PROJECT
Open a project from lazandroidmodulewizard/demos/Ant or lazandroidmodulewizard/demos/Eclipse directory
open ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1/jni/controls.lpi
from Project->Options, change/modify paths according to your system (under «paths» and «other»)
build it!
Now enter the shell, and cd's into ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1
edit build.sh and modify to reflect your system:

<?xml version="1.0" encoding="UTF-8"?>
<project name="AppDemo1" default="help">
<property name="sdk.dir" location="/home/renabor/Android/sdk"/>
<property name="target"  value="android-19"/>
<property file="ant.properties"/>
<fail message="sdk.dir is missing." unless="sdk.dir"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>

edit build.sh and leave only this line:
ant -Dtouchtest.enabled=true debug

- FROM COMMAND LINE
chmod +x ./build.sh
./build.sh
cd bin
~/Android/sdk/tools/android avd &
adb install AppDemo1-debug.apk

Enjoy!
Title: Re: Android Module Wizard
Post by: ps on February 08, 2015, 01:10:20 pm
Next hints for enhance:

Softkeyboard

Controls.java

Import part:
Code: [Select]
import android.view.inputmethod.EditorInfo;Source:
Code: [Select]
public  void setInputTypeEx(String str) {
  bufStr = new String(str.toString());
this.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

...

BorderColor
Remove border(frame):
Code: [Select]
this.setBackgroundColor(0);
HintText
Code: [Select]
this.setHint("This will be hint when edit box is empty");
PS: don't know anything about Java :)
Title: Re: Android Module Wizard
Post by: jmpessoa on February 15, 2015, 02:21:40 pm

Hi All!

Lamw: Lazarus Android Module Wizard [GitHub UPDATED!]

https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 14 - 13 February 2015 -

   NEW! Added support to Touch Gesture: Pinch/Zoom and Fling[Swipe]!
      :: [jPanel] Added/News events support:  OnFlingGesture and OnPinchZoomGesture

   NEW! Demo AppPinchZoomGestureDemo1 [Eclipse Compatible Project]
   NEW! Demo AppFlingGestureDemo1     [Eclipse Compatible Project]

   UPDATED! Demo AppActionBarTabDemo1 [Eclipse Compatible Project]
      :: Added support to gesture OnFlingGesture [swipe] //<<-A suggestion and request by Derit Agustin

   NEW! Added component jNotificationManager[Android Bridges Extras]
   NEW! Demo AppNotificationManagerDemo1[Eclipse Compatible Project]

   NEW! Added component jDatePicker[Android Bridges Extras]
   NEW! Added component jTimePicker[Android Bridges Extras]
   NEW! Demo AppDateTimePicker[Eclipse Compatible Project]

   IMPROVEMENTS:   jEditText :: Added/New method: SetImeOptions   //Thanks to @Ps
         All jVisualControl: Added Custom Color Support //Thanks to @Ps                
   UPDATED! Demo AppEditTextDemo1[Eclipse Compatible Project]
   
   UPDATED! All Demos updated!

Thanks to All!

Ps. @Ps,  thank you!
      @ renabor, thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 15, 2015, 03:45:44 pm
Hello

Thank you for Your work.

I have made a small calculator for my purpose.
Working time about 2 weeks  with studying and drawing.

Project properties
ANT
SDK tool Built 21.1.2
NDK 10C
Android 14
Target Android-17

I can give you the link on the result of me work if you are interested in it.

There were some difficulties.
I have some suggestions about the future versions, if it is possible to produce.
Sorry for non-professional description of the problems and advice. I am a chemist.

1. Failed to delete <uses-permission android:name="android.permission.READ_PHONE_STATE"/>. The app crashes.


2. For displaying  data from database and SQL queries used spinner

- spinner does not show more than 80-100 items (depends on number of characters), the app crashes;
- does not «count», and almost all properties and procedures  «item».
-  need the event   “onclick”  without selection;
- need «fontsize»;

3. «Jedittext»
- need the property «readonly» type;
- need an event type «onexit»;
- if форm 8 “Jedittext” with “maxtextlengh =300”, the app crashes;

4. Form.
- if create a form with “actRecyclable” or “actSplash” from form with “actRecyclable” or “actSplash” (3 form), does not work «backbutton» in the first form with “actMain”;
- Could not make FreeAndNill to form with «actRecyclable» or «actsplash».

5. The problem with string concatenation.
- this code does not work

var
A:real;
.....
stringlist:=tstringlist.Create;
stringlist.Add(A = '++floattostrf(A,ffFixed,10,2));
stringlist.free

it works

var
string_add:string;
.....
stringlist:=tstringlist.Create;
string_add:='A =';
string_add:= string_add +floattostrf(A,ffFixed,10,2);
stringlist.Add(string_add)
stringlist.free;



With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on February 15, 2015, 04:15:02 pm
Hi rx3!

Quote
...I can give you the link on the result of me work if you are interested in it....

Yes, I am interested! We can put it as "demo" ....

Ok, I will try fix and implement your suggestions!

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 15, 2015, 05:23:28 pm
Ok

The result here  https://yadi.sk/d/MozLnxSpeieyu
 

If you need the source for the demo, I will remove the math and will send the source via e-mail (e-mail?)
Code not a professional, I'm not a programmer.
To put or not to put you to decide

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on February 15, 2015, 08:38:26 pm
@rx3,

Great and nice work!

The demo need just GUI prototype... the math can be replaced by simple "ShowMessage"... So other people can learn to model a "Lamw" application.

Thank You.


Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 15, 2015, 09:38:07 pm
Thank you for rating.
Prepare a Demo in  near future.
How to pass?     
Can download on sourceforge.net.

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 16, 2015, 11:08:47 pm
Hello Jmpessoa


Did Demo.

Upload here with full version https://yadi.sk/d/MozLnxSpeieyu
Changed  previous link.
Use is on Your discretion.

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on February 18, 2015, 03:06:35 pm
Hi rx3!  [and All  :D]

I tried attend some of his suggestions! So you can improve your nice project!

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 15 - 17 February 2015 -

   MINOR IMPROVEMENTS:

   jApp:
      LOST properties: // <<--A suggestion and request by rx3.fireproof   
         Device.PhoneNumber
         Device.ID;
   jForm:
      NEWS methods:   
         .GetDevicePhoneNumber;
         .GetDeviceID;
         .[warning] "must have" [AndroidManifest.xml]:
            <uses-permission android:name="android.permission.READ_PHONE_STATE"/>         
   jTextView:
      NEW property: // <<--- Thanks to Fatih!      
         FontFace;

   jEditText:
      NEW properties: // <<--- Thanks to Fatih!      
         TextTypeFace;
         FontFace;
         Editable; <<-A suggestion and request by rx3.fireproof
   jSpinner:
      NEW properties:   <<-A suggestion and request by rx3.fireproof
         FontSize;
          Count;
   jHttpClient:
      NEWS methods: <<-A suggestion and request by Ps   
         .SetAuthenticationUser(...);        
         .SetAuthenticationHost(...);
      NEW property:   
         AuthenticationMode [just basic... yet]

   jWebView:
      NEW property: // <<--- Thanks to Fatih!   
         ZoomControl;   
      NEW method: <<-A suggestion and request by Ps
         SetHttpAuthUsernamePassword(...);
      
   jListView: FIXs [radio group mode]
      LOST property:   
         HighLightSelectedItem;
         ::Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"

Thanks!

P.S. [rx3:]

1. jSpinner: I added 3000 Items ... no problem! :-\
2. jEditText: OnEnter [just OnExit ... OnDone ... OnGo ]
 
Title: Re: Android Module Wizard
Post by: ps on February 18, 2015, 09:28:07 pm
Thank's for update and thank's for SetHttpAuthUsernamePassword  ;D

jHttpClient can be really hard to implement for real world situation I'm trying work with https. And this don't work easy in Android itself. Now I'm trying do something with okHttp (http://square.github.io/okhttp/). Problem is with self signed cert or with trusted cert but not supported with google.

Please look at TextHint property I requested. In Java code this.setHint("This will be hint when edit box is empty") this is very useful for search edi box and so on ...
Title: Re: Android Module Wizard
Post by: jmpessoa on February 19, 2015, 01:47:40 am
OK!

   jEditText:
      NEW property:
         HintTextColor; <<-A suggestion and request by Ps

Done!

P.S. [About HttpClient]
       You can try pure FPC/FCL  library ... !
Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 19, 2015, 01:52:01 am
Hello Jmpessoa

Thanks for the update.
I used it in the Demo. New Demo upload on the link above.

I have a spinner does not work.
I put in new demo database with large fetching of data.
Database name "rx3char.db". The base is copied to data/data/ when you first start.

Use in the AndroidModule2 is commented out in the procedure «Add_size»  and «AndroidModule2JNIPrompt» .

To test it is necessary to disable rx3.db and connect rx3char.db.

For example:
When selecting item "ГОСТ 8239-89", app works. Count items = 17.
When selecting item "ГОСТ 26020-83", app crashes count items >100
When selecting "ASTM A 6/A 6M – 12»,  app crashes also count items >200.

«rx3char.db» with strings, but in this case I think it is not important.
Added DecimalSeparator:=','  for app to work.

Please see what is wrong I am doing.

Continue to develop Your module, there are some difficulties.
1. Z order does not work in the design. If the component should be at the bottom, it should be put last.  For example background image. Change Z order cannot be.
2. In jSqliteDataAccess1.GetValueAsFloat does not work for «real» at me. :)



With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on February 19, 2015, 02:13:43 am
Ok I will try it!

About order:
If you need jImageView to match all background form, then put it first in the form!
But, if you need any component in bottom just configure PosRelativeToParent = [rpBottom] ... do not need anchor

Abou "real" ... change/cast to "single" ... there is not "real" compatible to android!

About  “maxtextlengh =300” .... changed! now maxtextlengh = -1 [default : no limited!!!]

Title: Re: Android Module Wizard
Post by: Stephano on February 21, 2015, 08:40:12 pm
Question 1:

Is there an easy way to create a simple android library (.so)?

Code: [Select]
library MyLibrary;
{$mode objfpc}{$H+}

function Add(a, b: integer): integer;
begin
  Result := a + b;
end;

exports
  Add name 'Java_Adder_Add';

begin
end.

Code: [Select]
package org.test.project1;

class Adder
{
  public native int Add(int a, int b);
  static
  {
    System.loadLibrary("mylibrary");
  }
}


QUestion 2:

How can we use the library from question 1 (.so without source code) in a LazAndroidModule project?
 case A: called from java code
 case B: called from pascal code
Title: Re: Android Module Wizard
Post by: Leledumbo on February 22, 2015, 02:25:41 pm
How can we use the library from question 1 (.so without source code) in a LazAndroidModule project?
 case A: called from java code
 case B: called from pascal code
case A:
You've had it in Question1 actually. Put the source in src directory, under correct package directory.
case B:
Put the lib in libs/<arch: armeabi, x86, mips, etc.> directory, you can call it from Pascal code in normal way to access dynamic library.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 22, 2015, 07:05:46 pm
Hi Stephano, [and All!]

I tried to answer your questions! 
[yes, the Leledumbo pointed the right and direct way!]

Please, get a new revision: 

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 18 - 22 February 2015 -

   ::Tutorial to Stephano Questions:

      1. Create a new "Lamw" project as usual [save all to ../jni]

      2. Add to ../src the new java class code [ex. jhelloadder.java]

      3. Go to [again] IDE->Project->New Project select [again] "JNI Android Module" Project
                   and [again] Select the same project [form workspace]

      4. But, NOW double click the added java class code [jhelloadder.java]

      5. Ok

      6. Save all new project to ../jni [warning: keep the project name [jhelloadder.lpr],
         but change the unit name :: ex. "unithelloadder.pas"]


      7. Yes, the new "jhelloadder.lpr" have the "drafts" code for all native methods!

         function Add(PEnv: PJNIEnv; this: JObject; _a: JInt; _b: JInt): JInt; cdecl;
         begin
             {your code....}
             {Result:= ;}
         end;

         function StringUpperCase(PEnv: PJNIEnv; this: JObject; _str: JString): JString; cdecl;
         begin
             {your code....}
             {Result:= ;}
         end;

      8. Yes, you have a new form [datamodule]: You can put there any "pure/fcl" TComponent descendant!
         [not LCL component, not Lamw component] --->> TODO: need more test

      9. Go to [again] IDE->Tools->Android Module Wizard->New jComponent [Create]

      10. Paste the "jhelloadder.java" into Tab "java" ...

                        WARNING: after paste, remove de word "public" from class definition!
                        [TODO: need fix the parse ...]
                                           
      11. Read the content of Tab "help" ... [follow the instructions!]

         Do not forget:

         //Please, you need insert:
            public java.lang.Object jHelloAdder_jCreate(long _Self) {
                    return (java.lang.Object)(new jHelloAdder(this,_Self));
               }
         //to end of "public class Controls" in "Controls.java"

      12. Open "tfpandroidbridge_pack.lpk --> More -> Recompile Clean -> Use -> Install !!
      13. Use Case 1: Pascal call Java :: drop the new component to jForm [main app] and use it!
      14. Use case 2. Java call Java   :: declare and use it! ex.:

         jHelloAdder helloadder;
         helloadder = new jHelloAdder(controls, 1010); //controsl=reference to main "controls" object :: 1010 = dummy
         Log.i("jHelloAdder_Add","Add(7,11)="+ helloadder.Add(7,11));

      15. Please,  see the new project demo ...   
      
   NEW! Demo AppAddSingleLibraryDemo1     [Eclipse Compatible Project]   


Thank you!

PS. Yes,  I will try a more simple [solution] library [no form at all!] just pure ".so"
Title: Re: Android Module Wizard
Post by: Stephano on February 22, 2015, 09:25:47 pm
I have read very quickly Leledumbo's and your replies, and will read them more carefully and make tests tomorrow. But I guess your suggestions rely on the fact that the source code of the 1st library is available when it is not.

To make my case clearer, let's say somebody sends me a libcontrols1.so (produced using lawm) and I want to use it either with lawm (or some other tool). My question is how to use it with lawm and have:
a- the java code make the calls to libcontrols1.so
b- the pascal code make the calls to libcontrols1.so
Title: Re: Android Module Wizard
Post by: tuntnguyen on February 23, 2015, 05:13:55 am
I have downloaded the lastest revision to reinstall lazandroidwizardpack.lpk
I still get this problem:

D:\laztoapk\lazandroidmodulewizard\androidwizard_intf.pas(179,15) Error: There is no method in an ancestor class to be overridden: "TAndroidWidgetMediator.GetObjInspNodeImageIndex(TPersistent,var LongInt);"

Code: [Select]
..
public
    // needed by TAndroidWidget
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean);
    property AndroidForm: jForm read FAndroidForm;
  public
    procedure GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); override;
  end; 

How to fix this?
I am using Lazarus 1.2.6 and FPC 2.6.4
Title: Re: Android Module Wizard
Post by: jmpessoa on February 23, 2015, 06:20:16 am
Hi tuntnguyen!

you need Lazaruss >= 1.3 and fpc >=2.7.1

The pratical solution [just for Windows]:

   -TrueTom [Laz4Android Package]

         Date:2014-10-18
         FPC: 2.7.1 SVN 28863  win32/arm-android/i386-android/jvm-android
         Lazarus:1.3 trunk svn 46592
         Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)
         http://sourceforge.net/projects/laz4android/files/?source=navbar
         :To Install, please, read the "Laz4Android_readme.txt"

For Linux, please read UP old posts.
Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 24, 2015, 11:30:26 am
Hello Jmpessoa

I updated arxdemo.

There are some problems.

1. The main problem

The demo works, but if you add in Androidmodule2 two jedittext, app crashes.

It is possible to correct by moving the procedure «add_nd» from  AndroidModule2JNIPrompt in a separate thread ( the weak point adding in spinner).
Don't want to create a thread.
I temporarily used jtimer =>> jTimer1Timer.

I'm not a programmer, but this is some kind of conflict the execution speed of the code.  %)

Probably need an event after AndroidModule2JNIPrompt, for example onShow or onActivite or afteJNIPrompt.

   
2 jmagebtn properties ImageUpIndetifier and ImageDownIndetifier not work.
For graphical buttons I used jimageview+jtimer. Looks decent, if you don't know what is it made of. ;)

   
3 jlistview.
If the property HighLightSelectedItemColor not equal colbrDefault, there may be problems with the removal of the last items. If you delete items twice  at the end of the list, the app crashes.

4 above z-order
Add a jbutton in AndroidModule2 and place it in the area jimageview3. The button cannot be pressed, the button will be under jimageview3.
You can't change the Z-order when designing forms , only to remove components and add in the correct order.



Have questions.

1. This code does not work.

stringlist:=Tstringlist.create;
……
stringlist.free;
……..
if stringlist<>nil then begin
stringlist.free;
end;

How to check whether there is object stringlist?

2. How to use code to disable speller (red line) in jedittext (Androidmodule5 arxdemo).


With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on February 25, 2015, 12:42:18 am
Hi @rx3,

I  will try implement yours suggestions!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on February 25, 2015, 02:27:42 am
Hi @Stephano,

Quote
...let's say somebody sends me a libcontrols1.so (produced using lawm) and I want to use it either with lawm (or some other tool). My question is how to use it with lawm ....

Quote
a- the java code make the calls to libcontrols1.so
b- the pascal code make the calls to libcontrols1.so ...

After some tests, I can share/show my findings:

1. As case study [simplification!] I make use of a very simple "libMyLib.so" 
[Ok, it was made by pure NDK using "C"]

You can get from here: https://jmpessoa.opendrive.com/files?Ml83NzE5Mjk1NV95QmRpUw 

The produce project [.rar] is here: https://jmpessoa.opendrive.com/files?Ml83NzE5MzU4OV9MTFZjMg

Why not a ".so" made by Lamw? Only because at the moment [as is] Lamw can not do a very very "raw" .so  [TODO list!] --- but everything written here works with a ".so"produced by Pascal/Lamw!

2. Here is the "MyLib.java" code:

Code: [Select]
package jmpessoa.ndktest;

public class MyLib {

   static {
        System.loadLibrary("MyLib");
    }

    public native int add(int x, int y);
    public native String getHello();
}

And here is the JNI "C" export  signature : [by libMyLib.so]
Code: [Select]
JNIEXPORT jint JNICALL Java_jmpessoa_ndktest_MyLib_add(JNIEnv *, jobject, jint, jint);
JNIEXPORT jstring JNICALL Java_jmpessoa_ndktest_MyLib_getHello(JNIEnv *, jobject);

And here is the JNI "Pascal/Lamw" equivalent exports signature:
Code: [Select]
function Java_jmpessoa_ndktest_MyLib_add(PEnv: PJNIEnv; this: JObject;  x:jInt, y:jInt): jInt;
function Java_jmpessoa_ndktest_MyLib_getHello(PEnv: PJNIEnv; this: JObject): jString;

Yes, this method name format is mandatory for JNI "Java_pagckagename_classname_methodname"

Question b [SOLVED!!!]: the Pascal/Lamw code can make calls to "libMyLib.so" !!

b.1 - Prepare to Linker [-Fl]

In my system I  Copied the "libMyLib.so" to C:\adt32\ndk10\platforms\android-13\arch-arm\usr\lib\

b.2 - Prepare to Apk

Copy "libMyLib.so"   to  "..\libs" yes, together with "libcontrols.so"

b.3 - Declare the library and methods in your Pascal/Lamw code:

Quote
const NATIVE_LIB = 'libMyLib.so';

function Add(PEnv: PJNIEnv; this: jObject; x: jInt; y:jInt): jInt; cdecl; external NATIVE_LIB name 'Java_jmpessoa_ndktest_MyLib_add';

function GetHello(PEnv: PJNIEnv; this: jObject): jString; cdecl; external NATIVE_LIB name 'Java_jmpessoa_ndktest_MyLib_getHello';

b.3 - Use it!

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  sum: integer;
  hello: string;
begin
   sum:= Add(gApp.Jni.jEnv,gApp.Jni.jThis,10,20);
   ShowMessage(IntTostr(sum));
   
   hello:= Get_pString( GetHello(gApp.Jni.jEnv,gApp.Jni.jThis) );
   ShowMessage(hello);

   //Get_pString <--> convert java string to pascal string   
end;

Yes!! Pascal/Lamw can use it!!

Considerations: in fact Pacal/Lamw no matter how the function name/signature was "designate" [exports],  so we can use any ".so" compiled to android/arm/x86 etc... even more complex made by Lamw!

Question a:  the java code make the calls to libMyLib.so

a.1 In the same/"natural" package [ no problem ....] just copy it to "...\libs"    and use it!

Code: [Select]
package jmpessoa.ndktest;

public class MainActivity extends Activity {

       //From JNI
       MyLib mylib = new MyLib();       
   
    String helloFromC = mylib.getHello();
    int sum = mylib.add(2,5);

    ...........................
}

a.2 In the "strange" package: NOT!!!

why? the original exported name JNI preface: "Java_jmpessoa_ndktest_"  need match!

Code: [Select]
package strange.test;

public class MyLib {

   static {
        System.loadLibrary("MyLib");
    }

    public native int add(int x, int y);
    public native String getHello();
}

Fail! Native method not found!
because: "Java_strange_test_MyLib_add"  and "Java_strange_test_MyLib_getHello" was expected but "Java_jmpessoa_ndktest_*" was found!

[workaround] You can force and design [your new project]  package "preface.name" as expected, that is: "jmpessoa.ndktest"!

conclusion: native Pascal/Lamw can do! java? need a workaround...

Thank you!

Title: Re: Android Module Wizard
Post by: truetom on February 25, 2015, 03:16:57 pm
Thank you jmpessoa, this is a great job!

Hello all,

I have updated laz4android to new version.

You can download from here:
http://sourceforge.net/projects/laz4android/

Laz4Android is a Lazarus for Android Package.
Thanks the FreePascal team and the Lazarus team.
Now Laz4Android is only run Windows.Sorry for this!

-------------------------------------------------------------------------------------
Last update:2015-02-25
FPC: 3.1.1 trunk svn 29987 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 47987
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

===============================================
Update history:
2014-04-05:
1.Fixed Android application crash problem,thanks DelphiFreak and Leslie.
-------------------------------------------------------------------------------------
2014-10-18:
FPC: 2.7.1 trunk svn 28863 win32/arm-android/i386-android/jvm-android
Lazarus:1.3 trunk svn 46592
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)
1.Fixed examples\androidlcl,now it can compatible with this version.
2.Compatible with Jmpessoa's LazAndroidModuleWizard,thanks Jmpessoa and Simonsays,links:
  https://github.com/jmpessoa/lazandroidmodulewizard
  http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html
-------------------------------------------------------------------------------------
2015-02-25:
FPC: 3.1.1 trunk svn 29987 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 47987
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)
1.Fixed examples\androidlcl\build_debug_apk.bat,now it can use JDK1.7 or JDK1.8 to Signing the APK.

===============================================
How to install Laz4Android?

1.You can download a installer file from here:
http://sourceforge.net/projects/laz4android/files/?source=navbar
- Double click the installer file
- Next , Next to finished.

-------------------------------------------------------------------------------------
2.You can download a 7z compressed file from here:
http://sourceforge.net/projects/laz4android/files/?source=navbar
- Unzip 7z file to e.g.  c:\laz4android
- Edit the file c:\laz4android\build.bat like this:

  SET FPC_BIN_PATH=c:\laz4android

Please run build.bat (double click it), it will compile and build lazarus.
===============================================

Thanks and best regards!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on February 27, 2015, 11:27:10 am
@truetom

Thank you very much!
 
Everything works on old projects.

There is one problem. Can't create a new project Lamw. Returned version 1.3

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: Stephano on February 27, 2015, 08:01:46 pm
@jmpessoa,
What do you mean by very very raw .so that Lawm cannot produce?
1- A pure Pascal library?
2- A pure Pascal library that makes jni calls?
3- A library that makes pascal code and jni calls and includes java code (for overriding methods)?
Title: Re: Android Module Wizard
Post by: jmpessoa on February 27, 2015, 10:53:55 pm
@Stephano,

Nothing like that ....I want to say:

As is,  the  minimalistic libray code produced by Lamw include:

TCustomApplication
TDataModule

as posted in  February 22, 2015, 04:05:46 pm explication ....

When, in fact,  in some cases, minimalistic code like below, could be enough [TODO list!]:  [basically to reuse and/or modularization]

Code: [Select]
library jhelloadder;  //[by LazAndroidWizard: 2/22/2015 4:52:05]

{$mode delphi}

uses
  Classes, SysUtils, jni;

function Add(PEnv: PJNIEnv; this: JObject; _a: JInt; _b: JInt): JInt; cdecl;
begin
  {your code....}
  Result:= _a + _b;
end;

function StringUpperCase(PEnv: PJNIEnv; this: JObject; _str: JString): JString; cdecl;
var
  _jboolean: jBoolean;
  pascalStr: string;
begin
  {your code....}
  case _str = nil of
    True : pascalStr:= '';
    False: begin
          _jboolean := JNI_False;
           pascalStr:= string(  PEnv^.GetStringUTFChars(PEnv,_str,_jboolean));
         end;
  end;
  Result:= PEnv^.NewStringUTF(PEnv, PChar(Uppercase(pascalStr)));  ;
end;

function JNI_OnLoad(VM: PJavaVM; reserved: pointer): JInt; cdecl;
var
 PEnv: PPointer;
begin
  PEnv:= nil;
  Result:= JNI_VERSION_1_6;
  (VM^).GetEnv(VM, @PEnv, Result);
end;

procedure JNI_OnUnload(VM: PJavaVM; reserved: pointer); cdecl;
begin
   //
end;

exports
  JNI_OnLoad name 'JNI_OnLoad',
  JNI_OnUnload name 'JNI_OnUnload',
  Add name 'Add',
  StringUpperCase name 'StringUpperCase';

begin
  //
end.   

At the moment to achieve this minimalistic code we need to strip the Lamw generated code...
But, again: everything written there/previous  ;D  works with any ".so" produced by Pascal/Lamw! Although they are more complex ...
Title: Re: Android Module Wizard
Post by: simonsayz on March 01, 2015, 03:19:48 pm
@jmpessoa
Really thanks for reply last year. :)
It's very helpful for me. and very sorry for the not supporting the Android Module Wizard' project.

I am starting to rewrite the base library.

Ref. http://blog.naver.com/simonsayz 
And_Controls_v0.26.zip (4.6MB)
- And_Controls : Conceptual Version (minimal, how to works)
- And_Controls : Modified Version
- Specification Doc (pptx)
- Sample App's Apk
Title: Re: Android Module Wizard
Post by: jmpessoa on March 01, 2015, 05:00:04 pm
Hi simonsayz!

Congratulations!!! Great Work!

I will try merge/adapt the news from  "And_controls_v0.26" and the news Demos to
Lamw/Android Module Wizard.

Thank you very much!
Title: Re: Android Module Wizard
Post by: simonsayz on March 02, 2015, 03:10:36 am
@jmpessoa

Thanks you. and sorry for the beta version always.
I will merge to your updated controls too.

iOS 64bit FPC Compiler was released by Jonas Maebe in last week.
So, My Plan is making the general mobile framework for FPC,Delphi

Maybe ... :)
And_Controls + iOS_Controls = XCL_Controls

Best Regards
Simon,Choi
Title: Re: Android Module Wizard
Post by: Leledumbo on March 02, 2015, 05:25:25 am
And_Controls + iOS_Controls = XCL_Controls
If you can create LCL backends with them too, we can have single source codebase for these platforms shared with desktop ones ;)
Title: Re: Android Module Wizard
Post by: simonsayz on March 02, 2015, 08:23:34 am
@Leledumbo

Verry Sorry and Thanks.

I'am just programmer with Free Pascal Compiler related "How it's works".
and, Prof jmpessoa has being released and updated the every version in last year.

And so, me and Jang want to remain the man on the supporter of Android module wizard.

But we (simon and jang) are working for the foward.

Thanks.
Simon and Jang
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 02, 2015, 11:16:39 am
Thanks for jIntentManager. Intents very easy to use.

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on March 09, 2015, 07:41:50 pm
Hi All!

I updated Lamw: Lazarus Android Module Wizard [MINOR CHANGES]

Version 0.6 - rev. 19 - 09 March 2015 -
   
   NEWS
      jControl: Added Method: AttachCurrentThread

      jHttpClient: Added Methods: PostNameValueData   

      jEditText: Added Methods:   
            SetAcceptSuggestion
            CopyToClipboard
            PasteFromClipboard
            Clear
      
   NEW! Demo AppAsyncTaskDemo1   [Eclipse Compatible Project]   
   NEW! Demo AppHttpClientDemo1   [Eclipse Compatible Project]   

   FIXs:   
           jAsyncTask
      jHttpClient

Thank to All!
Title: Re: Android Module Wizard
Post by: A.S. on March 10, 2015, 07:24:06 pm
Hello to all!
Is it possible to simulate (by program) hardware "back" button pressing?
Title: Re: Android Module Wizard
Post by: jmpessoa on March 10, 2015, 11:51:47 pm

In some cases you can try just:

Code: [Select]
  gApp.Finish;    //gApp --> global android App --> MainActivity


Title: Re: Android Module Wizard
Post by: A.S. on March 11, 2015, 07:01:12 pm
Indeed,  I want application to work in background (not to be finished).
I also noticed that if button have Visible property set to False at design time, changing it to True at runtime does not make button visible. Is it by design or a bug (or restriction)?
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 29, 2015, 01:40:04 pm
Hello Jmpessoa

For information
I solved my problem  № 4 from his post with «BackButton»

http://forum.lazarus.freepascal.org/index.php/topic,21919.msg169178.html#msg169178

Need to add "gapp.BaseIndex" here

procedure TAndroidModule2.AndroidModule2BackButton(Sender: TObject);
begin
gapp.BaseIndex:=0;
self.Close;
end;


Better   
gapp.BaseIndex:="ParentForm".FormIndex
"ParentForm" is the form from   which the next form.
Add to AndroidModuleCloseQuery.


There's a new problem.

Can't do a new project  ANT on Laz4Android 1.5 with FPC: 3.1.1.
Not seen lists with «platform», «minSDK», «targetApi». You cannot choose.
Not created «control.lpr».
Is it just me, or LAMW does not work with Laz4Android 1.5?
Maybe there are subtleties?
My LAMW in the folder C:\anroid\lazandroidmodulewizard-master\
Laz4Android in a folder 1.5 C:\anroid\Laz4Android

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on March 29, 2015, 07:07:41 pm
Hi rx3,

1. I Will put your solution in core code!

2. I just updated my Lamw stuff from github repository ....
[thanks to odisey1245/Anton and elera/Fatih  contributions!!!]
Well, everything continues to function normally in my 1.3 laz4android installation!
My workspace form picture is on Attachment ....

Can you post some workspace form picture from your installation?
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 29, 2015, 08:58:13 pm
@Jmpessoa
 

1. I Will put your solution in core code!
Glad to help.    

 

2. I just updated my Lamw stuff from github repository ....
[thanks to odisey1245/Anton and elera/Fatih  contributions!!!]
Well, everything continues to function normally in my 1.3 laz4android installation!
My workspace form picture is on Attachment ....

Can you post some workspace form picture from your installation?


This is a problem only with version Laz4android 1.5. 

The  Lists "Plaltform" , "minSDK",  "TargetApi" not visible. The lists are not displayed

Can't send a screenshot. I removed the version 1.5 and returned to 1.3. Install again version 1.5 does not want.
With version 1.3, everything is OK.

Only problem  N 1 of the post http://forum.lazarus.freepascal.org/index.php/topic,21919.msg169959.html#msg169959
 greatly limit the imagination and of course spiner.  :'(

I think a limit on the number of components on the form, is caused by incorrect calculation of the form layout. But I'm not a programmer.


With Respect

rx3.fireproof



Title: Re: Android Module Wizard
Post by: jmpessoa on March 29, 2015, 09:56:29 pm

Hi rx3!

About:
Quote
1. The main problem ....
ref. http://forum.lazarus.freepascal.org/index.php/topic,21919.msg169959.html#msg169959


Can you split these questions?

Thank you.
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 30, 2015, 01:26:04 am
@Jmpessoa

   
I will show

Take my demo.

Upgrade code templates

In Androidmodule2 remove jspinner1 and jspinner2

Comment out code with jspinners.

Add seven jEditText for example below jTextView5  -  the application works.

Add one more jEditText - the app crashes.

Delete the last two jEditText and add two JTextView - the app works.

Add one more JTextView- the app crashes.

Conclusion
On the form may be a limited number of visual components.
The number is determined by the component type.

This is the main problem for me


If a form contains jspinner, the number of components is reduced.


I think that the problem is the number of components and loading in jspinner related .

But now for me is more important than the number of components on the form.



 With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on March 30, 2015, 08:42:21 am

@rx3

Quote
...This is a problem only with version Laz4android 1.5. 
The  Lists "Plaltform" , "minSDK",  "TargetApi" not visible. The lists are not displayed ...

The FormWorkSpace  was fixed! Now Laz4android 1.5  is Ok!

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 30, 2015, 11:34:28 am
@Jmpessoa

 

The FormWorkSpace  was fixed! Now Laz4android 1.5  is Ok!
 

Now the lists are visible. The "control.lpr" and "jni" folder is not created.

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 30, 2015, 01:01:01 pm
@Jmpessoa

Last update Lamw from github repository with version 1.3 Laz4Android doesn't work either.
Reports cannot create build_x86.txt.
I use  Lamw 0.6 - Rev. 19 - 09 March 2015

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on March 30, 2015, 04:35:20 pm
@ rx3.fireproof

Please, use the new wizard entrypoint "JNI Android Module (GUI)" to create new project...

Thank you!

PS. I just now renamed the old entrypoint to "JNI Android Module (not GUI)" [under devolopment!] ... Sorry!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on March 30, 2015, 08:19:05 pm
 @Jmpessoa

Everything is working. Thank you.
I will wait for the solution to my main problem   :-[

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on March 31, 2015, 06:56:08 am
Hi All,

After some instability Lamw now has two entries [working!] to create new projects:

1. JNI Android Module [Lamw NoGUI]
Quote
A [NoGUI] JNI Android loadable module (.so)
using DataModule (NO Form Designer/Android Components Bridges)!

2. JNI Android Module [Lamw GUI]
Quote
A [GUI] JNI Android loadable module (.so)
based on Simonsayz's templates
with Form Designer and Android Components Bridges!

Thanks to All!

Special thanks to Anton/odisey1245, Fatih KILIÇ, rx3 and Leledumbo!

Title: Re: Android Module Wizard
Post by: rx3.fireproof on April 02, 2015, 03:36:53 pm
Hello Jmpessoa    


I want to use the jActionBarTab only on one form with ActiviteMode=actRecyclable. Is this possible?

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: rx3.fireproof on April 03, 2015, 11:39:15 am
Hello Jmpessoa   

There is a small problem with jEdittext.

If you touch, jEdittext in focus.
When the keyboard appears jEdittext moves above the keyboard.
 
If you press the BackButton, the keyboard disappears, jEdittext retains the focus.

If touched again jEdittext, keyboard covers jEdittext (jEdittext is already in focus).

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on April 03, 2015, 04:57:20 pm
@rx3

Quote
....When the keyboard appears jEdittext moves above the keyboard....

Please, try:

Code: [Select]
jEditText1.SetImeOptions(imeFlagNoFullScreen);

So,  IME will never go into full screen mode, and always leave some space to display the application UI.

There are others possibilities:
 
TImeOptions = (imeFlagNoFullScreen,
                 imeActionNone,
                 imeActionGo,
                 imeActionSearch,
                 imeActionSend,
                 imeActionNext,
                 imeActionDone,
                 imeActionPrevious,
                 imeFlagForceASCII);

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on April 04, 2015, 12:24:28 am
@ Jmpessoa

It did not help. On Android 4.03 everything is OK. When the second touch on Android 4.2.1 keyboard doesn't move jedit . I have API 17 can change?

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on April 04, 2015, 01:29:28 am
@rx3

Please, try  fix it in "OnChange" event ....

Code: [Select]
procedure TAndroidModule1.jEditText1Change(Sender: TObject; txt: string;
  count: integer);
begin
  jEditText1.SetImeOptions(imeFlagNoFullScreen);
end; 

Note: Did you put
Code: [Select]
     jEditText1.SetImeOptions(imeFlagNoFullScreen); 
in jForm "OnJNIPrompt" event? If not, please, test it there!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on April 04, 2015, 02:29:29 am
@ Jmpessoa

Now checked on the Samsung smartphone with 4.2.2 . Everything is working. Probably the problem directly in my Zoppo 950+ with 4.2.1.

Sorry

With Respect
rx3.fireproof

ps      
Going to torment tablet. On the tablet is a terrible layout. :o


 


Code: [Select]
procedure TAndroidModule1.jEditText1Change(Sender: TObject; txt: string;
  count: integer);
begin
  jEditText1.SetImeOptions(imeFlagNoFullScreen);
end; 

 

    
On zoppo is not working
Title: Re: Android Module Wizard
Post by: jmpessoa on April 04, 2015, 03:21:33 am
@rx3

Quote
...Going to torment tablet. On the tablet is a terrible layout. :o

Hint: study the examples using jForm "OnRotate" event and jPanel .... to control
UI layout!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on April 04, 2015, 03:43:40 am
@ Jmpessoa

The other problem.
Images are read from drawable-ldpi.
Big screen and small small pictures. The horror.
The images should probably be read from drawable-xxhdpi.
Probably need to write something in values-sw600dp .
I'm just not knowing how Android works.

 Murphy's law. If all else fails read the instructions ::)



With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on April 04, 2015, 04:32:16 am
@A.S

Code: [Select]
.....I also noticed that if button have Visible property set to False at design time,
changing it to True at runtime does not make button visible.
Is it by design or a bug (or restriction)?

It is by BUG!  :D :D :D :D

Sorry the late,  but now it was fixed!!!

Thank you!

@rx3

The Murphy's law in Brazilian version:

Quote
when something CAN go wrong.... Will go wrong!    :D :D
Title: Re: Android Module Wizard
Post by: jmpessoa on April 05, 2015, 02:00:37 am
Hi All,

Thanks to Anton (at  github.com/odisey1245)
the process to create new  android project and NOW build  Apk and run/install app in device has a improving integration with Lazarus IDE.

There is now a new "RUN --> Lamw: Build and Run"  IDE menu entry.

Thanks to All!

Special thanks to Anton for the many many contributions!

P.S: for old projecs, please change "controls.lpi":

after:
Code: [Select]
   <VersionInfo>
      <StringTable ProductVersion=""/>
    </VersionInfo>

Add this new entry:
Code: [Select]
    <CustomData Count="1">
      <Item0 Name="LAMW" Value="GUI"/>
    </CustomData>
Title: Re: Android Module Wizard
Post by: jmpessoa on April 08, 2015, 02:41:06 am
Hi All,

There is an updated revision of Lamw: Lazarus Android Module Wizard

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 20 - 07 April 2015

   NEWS:
      IDE menu entry "Run --> [Lamw] Build Apk and Run" ::by Anton


Quote
Note: for old projecs, please change "controls.lpi":

after:
Code: [Select]
   <VersionInfo>
      <StringTable ProductVersion=""/>
    </VersionInfo>

Add this new entry:
Code: [Select]
    <CustomData Count="1">
      <Item0 Name="LAMW" Value="GUI"/>
    </CustomData>

      IDE "New project" now has two entries [thanks to Anton!]:

         1. JNI Android Module [Lamw NoGUI]
            A [NoGUI] JNI Android loadable module (.so)
            using DataModule (NO Form Designer/Android Components Bridges)!

         2. JNI Android Module [Lamw GUI]
            A [GUI] JNI Android loadable module (.so)
            based on Simonsayz's templates
            with Form Designer and Android Components Bridges!
            
      New native method java Parse ::by Anton
      New property color editor ::by Anton

   NEW! Demo AppBluetoothDemo1 [Eclipse Compatible Project] <<---A suggestion and request by m4u_hoahoctro

Quote
      Note: to transfer file via Bluetooth,
      you need to do some common user's tasks:
      activate bluetooth, detect neighbors devices and pair neighbors devices....    

Thanks to All
Special thanks to Anton [at github/odisey1245]
Title: Re: Android Module Wizard
Post by: liuzg2 on April 08, 2015, 09:15:28 am
how to use  zxing jar packge
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 08, 2015, 12:08:15 pm
how to read and delete a sms on phone by jsms ?
Title: Re: Android Module Wizard
Post by: jmpessoa on April 08, 2015, 05:57:16 pm
@m4u_hoahoctro

1. Use the jSMS component to send SMS...
    At the moment do not exist support to read sms... sorry.

2. There is a new demo "AppBlueToothDemo1" ...  especially made for you!  ;D
     Please, study it! You will easily learn how to transfer file via bluetooth!

@ liuzg2

put it in project  .../libs

But, Lamw do not support this library at the moment, that is, does not exist a Pascal bind/bridge code ....sorry. What do this library?

Thank to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 09, 2015, 11:49:11 am
when I compile new packages ( new version), there is a error gtk2cellrenderer.pas(30,3) Fatal: Cannot find unit gtk2 used by Gtk2CellRenderer of package LCL.

and now, I can't open any demo in demo folder of lamw, form doesn't appear, I tried to re setup laz4andr and update newest version of lamw but I can't see form again
Title: Re: Android Module Wizard
Post by: jmpessoa on April 09, 2015, 04:19:30 pm
@m4u_hoahoctro,

To compile and (re)install a Lamw package you need a windows project open in Lazarus IDE!

You can't compile and install a Lamw package if a cross-compile/Lamw project is open!

from "install_tutorial_ant_users.txt" and "install_tutorial_eclipse_users.txt":

Quote
   HINT: to compile/install/reinstall a package in Laz4Android, please, open a "dummy"    windows project.... you always MUST close the cross compile project! 

Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 09, 2015, 04:47:34 pm
thanks, about sms problem, I think I will code it by elipse

but it appears 2 errors:
Missing styles. Is the correct theme chosen for this layout? and NOTE: This project contains resource errors, so aapt did not succeed, which can cause rendering failures. Fix resource problems first.

I did:  For that Right click on project name in Project Explorer -> Android Tools -> Fix Project Properties and then "Clean project" (Project -> Clean).

but there is still an error:

[2015-04-09 21:45:42 - sms] D:\work\sms\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. [2015-04-09 21:45:42 - sms] [2015-04-09 21:45:42 - sms] D:\work\sms\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. [2015-04-09 21:45:42 - sms] [2015-04-09 21:45:42 - sms] D:\work\sms\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. [2015-04-09 21:45:42 - sms]
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 09, 2015, 04:59:21 pm
To compile and (re)install a Lamw package you need a windows project open in Lazarus IDE!

You can't compile and install a Lamw package if a cross-compile/Lamw project is open!

Quote
   HINT: to compile/install/reinstall a package in Laz4Android, please, open a "dummy"    windows project.... you always MUST close the cross compile project! 

Thank you!

I am not well at english, so when you say " need a windows project open in Lazarus IDE!" , does it mean I need choose File>New>App ?  :)
humm, and may be I should improve my eng skill more  :) :) :)
Title: Re: Android Module Wizard
Post by: jmpessoa on April 09, 2015, 05:56:47 pm

@m4u_hoahoctro

You need open a common/trivial window project! Not a Lamw project!

Just curiosity: What is your main speak language? My is Portuguese!
Title: Re: Android Module Wizard
Post by: A.S. on April 09, 2015, 06:45:56 pm
m4u_hoahoctro, check dependencies of your project. I think, LCL becomes a part of them. If so, remove it.
Title: Re: Android Module Wizard
Post by: rx3.fireproof on April 10, 2015, 12:17:52 am
Hello Jmpessoa

For information.

I found a pseudo solution to my main problem.
 
I moved all the code from "AndroidModuleJNIPrompt" to "jTimerTimer" .
 
Now in "AndroidModuleJNIPrompt" only  "jtimer.enable:=true"  with "jtimer.interval:=20"

 

With Respect

rx3.fireproof



Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 10, 2015, 06:47:07 am

@m4u_hoahoctro

You need open a common/trivial window project! Not a Lamw project!

Just curiosity: What is your main speak language? My is Portuguese!

I am vietnamese  :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 10, 2015, 10:35:58 am
I choose menu file>new>application
then I compile and install all new packages, all are ok. But I can't see anyandroidmodule from your demo folder, althought I can see all android modules from my projects.

and: I also can't receive apk file from above projects when run build-debug.bat (error message is: Panic: internal error: missing executable "" )

Did I do it amiss ?  :(
Title: Re: Android Module Wizard
Post by: jmpessoa on April 11, 2015, 02:04:19 am
@m4u_hoahoctro

Quote
... I can't see anyandroidmodule from your demo folder

The demo folder has two folder: Ant and Eclipse..... if you choice Eclipse folder you can see: many demos applications. For example:   ....\demos\Eclipse\AppBluetoothDemo1

If you open  "jni" folder you can see the  lazarus project "controls.lpi".

Alternatively you can go to Lazaru IDE  --> "Project --> Open Project"  and go to

"...\demos\Eclipse\AppBluetoothDemo1\jni" and open the "controls.lpi"

but you need modify "controls.lpi"  in two places according to your system paths:

1.
Code: [Select]
    <SearchPaths>
      <Libraries Value="C:\adt32\ndk10\platforms\android-15\arch-arm\usr\lib\;C:\adt32\ndk10\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.6\"/>
      <UnitOutputDirectory Value="..\obj\controls"/>
    </SearchPaths>

2.
Code: [Select]
    <Other>
      <CustomOptions Value="-Xd -CfSoft -CpARMV6 -XParm-linux-androideabi- -FDC:\adt32\ndk10\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin -o..\libs\armeabi\libcontrols.so"/>
    </Other>

in fact path "C:\adt32\ndk10\" is the configuration of my system.... change it to conform with your system....

Quote
Note: But to simply learn from the example code you need only study "unit1.pas" and "unit1.lfm"
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 11, 2015, 04:41:02 am
@m4u_hoahoctro

Quote
... I can't see anyandroidmodule from your demo folder

The demo folder has two folder: Ant and Eclipse..... if you choice Eclipse folder you can see: many demos applications. For example:   ....\demos\Eclipse\AppBluetoothDemo1

If you open  "jni" folder you can see the  lazarus project "controls.lpi".

Alternatively you can go to Lazaru IDE  --> "Project --> Open Project"  and go to

"...\demos\Eclipse\AppBluetoothDemo1\jni" and open the "controls.lpi"

but you need modify "controls.lpi"  in two places according to your system paths:

1.
Code: [Select]
    <SearchPaths>
      <Libraries Value="C:\adt32\ndk10\platforms\android-15\arch-arm\usr\lib\;C:\adt32\ndk10\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.6\"/>
      <UnitOutputDirectory Value="..\obj\controls"/>
    </SearchPaths>

2.
Code: [Select]
    <Other>
      <CustomOptions Value="-Xd -CfSoft -CpARMV6 -XParm-linux-androideabi- -FDC:\adt32\ndk10\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin -o..\libs\armeabi\libcontrols.so"/>
    </Other>

in fact path "C:\adt32\ndk10\" is the configuration of my system.... change it to conform with your system....

Quote
Note: But to simply learn from the example code you need only study "unit1.pas" and "unit1.lfm"

source editor window doesn't appear, and it's forms, too :(
I go to menu window> but it doesn't have Source Editor and Androidmodule option
Title: Re: Android Module Wizard
Post by: jmpessoa on April 11, 2015, 05:26:17 am
@m4u_hoahoctro

For Lamw, You need the following packages installed in that order:

1.tfpandroidbridge_pack.lpk

2. lazandroidwizardpack.lpk

and look for  .../ide-tools

3.amw_ide_tools.lpk

and again:

Quote
HINT: to compile/install/reinstall a package in Laz4Android, please, open a "dummy"    Windows project.... you always MUST close the cross compile[Lamw] project! 
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 11, 2015, 06:33:25 am
Problem is still appears. I can create new and build my project, but can't see source editor when open your demo.
as this (your demo), it doenst have source editor option

p.s:All packages were installed successfully, so I think error is different place

Title: Re: Android Module Wizard
Post by: jmpessoa on April 11, 2015, 06:55:11 am
Sorry!


Please do as follows:

Lazarus IDE menu:  "Project" --> "View Project Source"

and:

Lazarus IDE menu:  "Project" --> "Forms...."

Thank You!

Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 11, 2015, 07:36:28 am
thanks very much  :) now all worked
and I hope you will update reading sms to jsms soon  ;D
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 11, 2015, 08:09:10 am
ooops
what is this window ? (open demo ActionBartab)

Title: Re: Android Module Wizard
Post by: Leledumbo on April 11, 2015, 08:49:07 am
ooops
what is this window ? (open demo ActionBartab)
That's what happened when you open a project relying on components whose certain published properties are removed. The fix is trivial, though. Simply open the .lfm and delete the respective propert(y|ies) line(s).
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 11, 2015, 12:27:06 pm
I saw demo AppBluetooth1 and do as it:

Code: [Select]
procedure TAndroidModule1.jButton3Click(Sender: TObject);
var jimage:jobject;
  varcop:boolean;
begin
  jimage:=jimagefilemanager1.LoadFromAssets('doremon.jpg');
  jimagefilemanager1.SaveToFile(jimage,'doremon.jpg');
  varcop:=self.CopyFile(self.GetEnvironmentDirectoryPath(dirInternalAppStorage)+'/doremon.jpg',Self.GetEnvironmentDirectoryPath(dirSDCard)+'/doremon.jpg');
  if varcop then
  begin
  direnv:=TEnvDirectory.dirSdCard;
  jbluetooth1.SendFile(self.GetEnvironmentDirectoryPath(direnv),'doremon.jpg','image/jpg');
  end;
end;         

but when run on my phone (android 2.3)
the app notes: The application parents(my  project name) (process org.lazarus.parents) has stopped unexpectedly. Pease try again

and with this code: my app also auto closes (on phones use android 2.3 and 4.2.2),although bluestack can play it:

Code: [Select]
procedure TAndroidModule1.jButton2Click(Sender: TObject);
begin
 name1:=tstringlist.create;
 name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
 showmessage(name1.strings[0]);
end;   

Title: Re: Android Module Wizard
Post by: jmpessoa on April 11, 2015, 07:01:57 pm
@m4u_hoahoctro

1.

Quote
ooops
what is this window ? (open demo ActionBartab)

If you prefer you can just choice "Continue Loading" .... but then you will need simulate any property change [ex tag=3] and SAVE to fix the error....

2. some attempts: 
2.1 try 'image/*'   or    'image/jpeg' 
2.2 try copy to  others [public!] folder [ex. /Downloads]

3. some attempt:  showmessage(name1.text);
just hint: you nedd too "name1.Free;"
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 12, 2015, 01:42:44 am
I tried:

Code: [Select]
{Hint: save all files to location: D:\laz4\parents\jni }
unit unit1;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls, unit6, unit5,
  unit4, Laz_And_Controls_Events, AndroidWidget,textfilemanager;

type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
    jButton1: jButton;
    jButton2: jButton;
    jButton3: jButton;
    jButton4: jButton;
    jButton5: jButton;
    jButton6: jButton;
    jButton7: jButton;
    jButton8: jButton;
    jTextFileManager1: jTextFileManager;
    procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule1: TAndroidModule1;
implementation

{$R *.lfm}

{ TAndroidModule1 }


procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
name1:=tstringlist.create;
 name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
 showmessage(name1.text);
 name1.free;
end;


end.

but the app still closes immediately when open it (test on samsung galaxy Y  using andr 2.3)

humm, does my phone is too old,so it can't play this app ?



Title: Re: Android Module Wizard
Post by: jmpessoa on April 12, 2015, 02:05:07 am
@m4u_hoahoctro

Quote
.... humm, does my phone is too old,so it can't play this app ?

May be ... has been difficult to maintain compatibility for android < 3

You can run any other application?
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 12, 2015, 05:15:37 am
I also tried above app on phone using android 4.2, and it also closes  :-\
Title: Re: Android Module Wizard
Post by: jmpessoa on April 12, 2015, 06:09:22 am
@m4u_hoahoctro

Please, send me your project [*.zip or *.rar] , I will try it!

 ----->>> jmpessoa_hotmail_com
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 12, 2015, 06:52:59 am
this is it
https://app.box.com/s/q2in6j91i6mz1d3jrnzxg0is0x79ghit (https://app.box.com/s/q2in6j91i6mz1d3jrnzxg0is0x79ghit)
Title: Re: Android Module Wizard
Post by: jmpessoa on April 12, 2015, 07:25:43 am
@m4u_hoahoctro

Quote
Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
 name1:=tstringlist.create;
 name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
 showmessage(name1.text);
 name1.free;
end;

Where
Code: [Select]
var name1: TStringList
was declared?  :o

try  this:

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  name1: TStringList;   //<<--------
begin
 name1:=tstringlist.create;
 name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
 showmessage(name1.text);
 name1.free;
end;
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 12, 2015, 08:39:43 am
it worked on 4.4.3 ( phone of my friend), I set target api is 17 and minsdk is 8. so how differrent between api 17 and 19 ?

and what is Android Module JNI Prompt used for ?
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 12, 2015, 01:36:37 pm
humm, error again:
Press build and run, then laz notes:
Fatal: [Exception] Failed: Cannot build APK!
Title: Re: Android Module Wizard
Post by: A.S. on April 12, 2015, 02:47:50 pm
m4u_hoahoctro, there should be another error messages.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 12, 2015, 08:50:44 pm
@m4u_hoahoctro

Quote
....Press build and run

That is: Lazarus IDE menu "Run--> [Lamw] Build and Run" ?

Quote
         Note: for old projecs [before rev. 20 - 07 April 2015], please change "controls.lpi":

         after:
Code: [Select]
<VersionInfo>
    <StringTable ProductVersion=""/>
</VersionInfo>
         Add this new entry:
Code: [Select]
<CustomData Count="1">
    <Item0 Name="LAMW" Value="GUI"/>
</CustomData>

Please, set minAPI >= 11
Title: Re: Android Module Wizard
Post by: liuzg2 on April 13, 2015, 04:21:33 am
zxing is  barcode scan  liabry   for  ios  andriod ,windows .
it is a very Important  for app
Title: Re: Android Module Wizard
Post by: jmpessoa on April 14, 2015, 05:58:28 am
@ liuzg2

Ok, I searched and found a trivial [and recommended] solution
but you need the ZXing App Installed  in your device [it is free!]

ref.  http://androidcookbook.com/Recipe.seam?recipeId=3324 

Yes, Lamw can use  ZXing to scan bar code for us! Follows a simple code  demonstration:

1. Call ZXing App barcode scanner using jIntentManager:

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin

     jIntentManager1.SetAction('com.google.zxing.client.android.SCAN');

     jIntentManager1.PutExtraString('SCAN_MODE', 'PRODUCT_MODE');   //Prod

     //or jIntentManager1.PutExtraString('SCAN_MODE', 'QR_CODE_MODE');   //QR
     //or jIntentManager1.PutExtraString('SCAN_FORMATS','CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF'); //others
   
     //Call ZXing Barcode Scanner to scan for us:
     jIntentManager1.StartActivityForResult(0);      //user-defined requestCode= 0

end;

2. And get the result here [jForm OnActivityRst event]:

Code: [Select]
procedure TAndroidModule1.AndroidModule1ActivityRst(Sender: TObject;
  requestCode, resultCode: Integer; jIntent: jObject);
begin
  if  requestCode =  0 then  //user-defined requestCode= 0
  begin
    if resultCode = -1 then  //ok
    begin

        ShowMessage('FORMAT: '+jIntentManager1.GetExtraString(jIntent, 'SCAN_RESULT_FORMAT'));
        ShowMessage('CONTENT: '+jIntentManager1.GetExtraString(jIntent, 'SCAN_RESULT'));

    end else ShowMessage('Fail/cancel to scan....');
  end;
end;

Thank you!
Title: Re: Android Module Wizard
Post by: liuzg2 on April 15, 2015, 02:31:24 am
1  yes  great  it works
but 

jIntentManager1.GetExtraString(jIntent, 'SCAN_RESULT')
result is null
jIntentManager1.GetExtraString(jIntent, 'SCAN_RESULT_FORMAT'));
result is null

2
  i use lazforandroid  and the last your packge 
when i create new gui  ,it can not load  'App.java'
 
Title: Re: Android Module Wizard
Post by: jmpessoa on April 15, 2015, 05:36:48 am
@liuzg2

2.
Quote
...when i create new gui  ,it can not load  'App.java'...
Supposing you have chosen new project as "JNI Android Module [Lamw GUI]"
and Eclipse [where "MainActivity" MUST be called "App"].... I do just now a new test... and I not got this mistake ...

1.
Quote
...result is null...
I do just now a new test... and I not got this mistake too ...
Maybe you need a little more accuracy with scan process....

You can see my results in  attachments [pictures] ...
Title: Re: Android Module Wizard
Post by: jmpessoa on April 16, 2015, 05:13:06 pm
Hi All

I just uploaded a new app demo to show the bar code reading... 

AppIntentDemoZXing1 [Eclipse Compatible Project]

https://github.com/jmpessoa/lazandroidmodulewizard

Here is the basic code [improved!].

1. [Try] Call ZXing App barcode scanner using jIntentManager:

Code: [Select]
procedure TAndroidModule1.jListView1ClickCaptionItem(Sender: TObject;
  Item: integer; caption: string);
begin

   jIntentManager1.SetAction('com.google.zxing.client.android.SCAN');
   if  jIntentManager1.IsCallable(jIntentManager1.GetIntent()) then
   begin
       //ShowMessage('ZXing App is Installed!! ');

       case Item of
          0: jIntentManager1.PutExtraString('SCAN_MODE', 'PRODUCT_MODE');   //Prod
          1: jIntentManager1.PutExtraString('SCAN_MODE', 'QR_CODE_MODE');   //QR
          2: jIntentManager1.PutExtraString('SCAN_FORMATS', 'CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF'); //others
       end;

       //ZXing Barcode Scanner to scan for us
       jIntentManager1.StartActivityForResult(0);      //user-defined requestCode= 0

   end
   else  //download ZXing
   begin
      ShowMessage('Try downloading   ZXing App ...');
      if not Self.IsWifiEnabled() then Self.SetWifiEnabled(True);
      jIntentManager1.SetAction(jIntentManager1.GetActionViewAsString());
      //or jIntentManager1.SetAction('android.intent.action.VIEW');
      jIntentManager1.SetDataUri(jIntentManager1.ParseUri('market://search?q=pname:'+'com.google.zxing.client.android'));
      jIntentManager1.StartActivity();
   end;
end; 

2.And get the result here [jForm OnActivityRst event]:

Code: [Select]
procedure TAndroidModule1.AndroidModule1ActivityRst(Sender: TObject;
  requestCode, resultCode: Integer; jIntent: jObject);
begin
  if  requestCode =  0 then  //user-defined requestCode= 0
  begin
    if resultCode = -1 then  //ok
    begin
        ShowMessage('FORMAT: '+jIntentManager1.GetExtraString(jIntent, 'SCAN_RESULT_FORMAT'));
        ShowMessage('CONTENT: '+jIntentManager1.GetExtraString(jIntent, 'SCAN_RESULT'));
    end else ShowMessage('Fail/cancel to scan....');
  end;
end;

Thank to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 17, 2015, 02:48:48 pm
how can i get itemindex (number of item clicked) same as function listview1.itemindex of TListview on lazarus ? :o
Title: Re: Android Module Wizard
Post by: jmpessoa on April 17, 2015, 06:42:25 pm
@m4u_hoahoctro

Quote
....how can i get itemindex (number of item clicked)....

In event "ClickCaptionItem"  or ClickItem [jListView]:

Code: [Select]
procedure TAndroidModule1.jListView1ClickCaptionItem(Sender: TObject; Item: integer; caption: string);
begin
       case Item of
          0: ............
          1: ...........
          2: ...........
       end;
end; 

There is too IsItemChecked(index: integer) when you have a checkbox or radio button composing you item row;
Code: [Select]
  if jListView1.IsItemChecked(1) then ....
  else ......
 

Thank You.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 18, 2015, 05:21:47 am
thanks, and :-[
I am using Bluestacks as a virtual android device,but I don't know where virtual sd card drive is, please help :-\
Title: Re: Android Module Wizard
Post by: jmpessoa on April 18, 2015, 05:43:45 am
@m4u_hoahoctro

Sorry... I do not know Bluestacks virtual device ....

But I can say to you: if possible use real device! 

Virtual device is the origin of many strangers problems!
Title: Re: Android Module Wizard
Post by: Leledumbo on April 18, 2015, 06:19:18 am
thanks, and :-[
I am using Bluestacks as a virtual android device,but I don't know where virtual sd card drive is, please help :-\
I think you should ask bluestacks maintainer instead of us. Surely they know their product best.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 26, 2015, 12:03:45 pm
I used this code with Button1, but on phone using android 4.2, it auto closes
so where is error ?
Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var cpyok:boolean;
begin
  cpyok:=Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirInternalAppStorage)+'/hello.txt',Self.GetEnvironmentDirectoryPath(dirSDCard)+'/hello.txt');
  if cpyok then showmessage('complete') else showmessage('error');
end;   

link of project:
https://app.box.com/s/z4mtl4g666atyxeqgc2306p0u8szikef (https://app.box.com/s/z4mtl4g666atyxeqgc2306p0u8szikef)
Title: Re: Android Module Wizard
Post by: jmpessoa on April 27, 2015, 11:18:34 pm
@ m4u_hoahoctro

"dirInternalAppStorage" is the internal location where your App save files....  so, "hello.txt"  need be a file created and saved by your App... is that right?
Title: Re: Android Module Wizard
Post by: horacio_ar on May 02, 2015, 02:38:28 am
jmpessoa: your work is impressive! very good job!
I tried Delphi XE8, and it works... but produce extra big application.
I tried Lazarus with customdraw, and is usefull for some things, but not native widgents. The edit control have some issues.
Then I tried AMW and got the best first impression!
Now the things I need to continue:
1) How to set the ActiveControl property to the form (the one that will have the focus on start)?
2) How to set the TabOrder?
I have 2 jEditText controls on the form and 1 jButton. Pressing NEXT on keyboard on the first control shoud activate the seccond one... For the seccond one the keyboard should say Finish (or so) and on activate this key should call the OnClic of the button. how to do this?
3) The 2nd jEditText control must accept only some characters. In this case it should allow only HEX characters (0 to 9 and A to F)... I did not found the way to do this... how can I do this?
4) I want to interact with a MS SQL Server. For this I fould jTds java library. I tried to understand how to create the components for this, but I was unable to find the approach? Any hint on this will be appreciated.
Other option should be using SqlDB, but need the .so library and I was unable to find it anyware.
Thats all for now.
Horacio
Title: Re: Android Module Wizard
Post by: jmpessoa on May 02, 2015, 04:39:00 am
@horacio_ar

1. You can try handle the event "OnJNIPrompt" from jForm

Code: [Select]
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
    jEditText1.SetFocus;
end;

2. You can try handle the event "OnEnter" from jEditText
[enter  --->  "enter" or "done" or "next" or "go" ...]

Code: [Select]
procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
     jEditText2.SetFocus;
end;

3. jEditText has the property "InputTypeEx" but very limited yet [I will try improve it!]

4. You can try "SQL Server"  via jHttpClient ... I do not know about sql client in android...

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 03, 2015, 06:02:57 pm
Hello Jmpessoa


How to destroy the form (Androidmodule) and to free the memory. In my program are 23 forms (Androidmodule). If everything is created, the application is in memory of about 120 mb.

Now I am using a form with «actSplash».

I tried to use «self.finish». The form is destroyed, but not created again.

If it possible, show an example code.



With Respect
rx3.fireproof

ps        
I posted my app in Yandex.store :D
Thank you!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 06, 2015, 09:08:16 am
   Lazarus Android Module Wizard
                 "Form Designer and Components development model!"
      
   "A wizard to create JNI Android loadable module (.so) in Lazarus/Free Pascal using
   [datamodule like] Form Designer and Components!"

   Author: Jose Marques Pessoa : jmpessoa__hotmail_com

      https://github.com/jmpessoa/lazandroidmodulewizard

Please, to start:
   "readme.txt"
   "install_tutorial_ant_users.txt"
   "install_tutorial_eclipse_users.txt"

Acknowledgements: Eny and Phil for the Project wizard hints...
                  http://forum.lazarus.freepascal.org/index.php/topic,20763.msg120823.html#msg120823

                  Felipe for Android support....

                  TrueTom for Laz4Android Package (laz4android1.1-41139)...
                  https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6%21149

                  Lazarus forum community!

version 0.1 - August 2013

[1]Warning: at the moment this code is just a *proof-of-concept*

I. INSTALL LAZARUS PACKAGE (laz4android1.1-41139)

   1. From lazarus IDE

      1.1 Package -> Open Package -> "lazandroidwizardpack.lpk"
   
      1.2 From Package Wizard
          1.2.1 Compile
          1.2.2 Use -> Install

II. USE

1. From Eclipse IDE

  1.1. File -> New -> Android Application Project

  1.2. From Package Explore -> src
   
       Right click your recent created package -> new -> class 
   
       Enter new class name... (ex. JNIHello)
   
       Edit class code for wrapper native methods (ex...)

Code: [Select]

                package org.jmpessoa.app1;
 
public class JNIHello {

   public native String getString(int flag);
   public native int getSum(int x, int y);

                   static {
try {
          System.loadLibrary("jnihello");           
} catch(UnsatisfiedLinkError ule) {
    ule.printStackTrace();
}
                   }
             } 


  1.3. warning: System.loadLibrary("...") must match class Name lower case...
       ex. JNIHello -> "jnihello"

2. From lazarus IDE (laz4android1.1-41139)

   2.1 Project -> New Project
   2.2 JNI Android Module

2.1. From JNI Android Module set Paths
   2.1.1 Path to Eclipse Workspace
       ex. C:\adt32\eclipse\workspace
           
   2.1.2 Path to Ndk Plataforms
       ex. C:\adt32\ndk7\platforms\android-8\arch-arm\usr\lib
 
   2.1.3 Path to Ndk Toolchain 
       ex. C:\adt32\ndk7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.4.3

2.2. From JNI Android Module select Java wrapper class for native methods.... (ex JNIHello)

2.3. OK! 

2.3.1 - Data Module Form Code:

Code: [Select]
{Hint: save all files to location: C:\adt32\eclipse\workspace\App1\jni }
unit unit1;
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils;
 
type
  TAndroidModule1 = class(TDataModule)
    private
      {private declarations}
    public
      {public declarations}
  end;
 
var
  AndroidModule1: TAndroidModule1;

implementation
 
{$R *.lfm}
 
end.

2.3.2. Library Code:
Code: [Select]
{hint: save all files to location: C:\adt32\eclipse\workspace\App1\jni }
library jnihello;
 
{$mode delphi}
 
uses
  Classes, SysUtils, CustApp, jni, Unit1;
 
const
  curClassPathName: string='';
  curClass: JClass=nil;
  curVM: PJavaVM=nil;
  curEnv: PJNIEnv=nil;
 
type
 
  TAndroidApplication = class(TCustomApplication)
   public
     procedure CreateForm(InstanceClass: TComponentClass; out Reference);
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
  end;
 
procedure TAndroidApplication.CreateForm(InstanceClass: TComponentClass; out Reference);
var
  Instance: TComponent;
begin
  Instance := TComponent(InstanceClass.NewInstance);
  TComponent(Reference):= Instance;
  Instance.Create(Self);
end;
 
constructor TAndroidApplication.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  StopOnException:=True;
end;
 
destructor TAndroidApplication.Destroy;
begin
  inherited Destroy;
end;
 
var
  Application: TAndroidApplication;
 
{ Class:     org_jmpessoa_app1_JNIHello
  Method:    getString
  Signature: (I)Ljava/lang/String; }
function getString(PEnv: PJNIEnv; this: JObject; flag: JInt): JString; cdecl;
begin
  {your code....}
  {Result:=;}
end;

{ Class:     org_jmpessoa_app1_JNIHello
  Method:    getSum
  Signature: (II)I }
function getSum(PEnv: PJNIEnv; this: JObject; x: JInt; y: JInt): JInt; cdecl;
begin
  {your code....}
  {Result:=;}
end;

const NativeMethods:array[0..1] of JNINativeMethod = (
   (name:'getString';
    signature:'(I)Ljava/lang/String;';
    fnPtr:@getString;),
   (name:'getSum';
    signature:'(II)I';
    fnPtr:@getSum;)
);

function RegisterNativeMethodsArray(PEnv: PJNIEnv; className: PChar; methods: PJNINativeMethod; countMethods:integer):integer;
begin
  Result:= JNI_FALSE;
  curClass:= (PEnv^).FindClass(PEnv, className);
  if curClass <> nil then
  begin
    if (PEnv^).RegisterNatives(PEnv, curClass, methods, countMethods) > 0 then Result:= JNI_TRUE;
  end;
end;
 
function RegisterNativeMethods(PEnv: PJNIEnv): integer;
begin
  curClassPathName:= 'org/jmpessoa/app1/JNIHello';
  Result:= RegisterNativeMethodsArray(PEnv, PChar(curClassPathName), @NativeMethods[0], Length(NativeMethods));
end;
 
function JNI_OnLoad(VM: PJavaVM; reserved: pointer): JInt; cdecl;
var
  PEnv: PPointer {PJNIEnv};
begin
  PEnv:= nil;
  Result:= JNI_VERSION_1_6;
  (VM^).GetEnv(VM, @PEnv, Result);
  if PEnv <> nil then RegisterNativeMethods(PJNIEnv(PEnv));
  curVM:= VM {PJavaVM};
  curEnv:= PJNIEnv(PEnv);
end;
 
procedure JNI_OnUnload(VM: PJavaVM; reserved: pointer); cdecl;
begin
  if curEnv <> nil then (curEnv^).UnregisterNatives(curEnv, curClass);
  curClass:= nil;
  curEnv:= nil;
  curVM:= nil;
  Application.Terminate;
  FreeAndNil(Application);
end;

exports
  JNI_OnLoad name 'JNI_OnLoad',
  JNI_OnUnload name 'JNI_OnUnload',
  getString name 'Java_org_jmpessoa_app1_JNIHello_getString',
  getSum name 'Java_org_jmpessoa_app1_JNIHello_getSum';
 
begin
  Application:= TAndroidApplication.Create(nil);
  Application.Title:= 'My Android Library';
  Application.Initialize;
  Application.CreateForm(TAndroidModule1, AndroidModule1);
end.

2.4. follow the code hint: "save all files to location....."

2.5. From Lazarus IDE (laz4android1.1-41139)
     Run -> Build

III. BUILD AND RUN ANDROID APPLICATION

     1.  From Eclipse IDE

     1.1 right click your recent created project -> Run as -> Android Application

IV.  GIT HUB

     https://github.com/jmpessoa/lazandroidmodulewizard

     To facilitate follows first code release on attachment (*.rar) and some interface pictures...

     Have Fun!



how to use Android Module Wizard  to run a command line which in /system/bin
Title: Re: Android Module Wizard
Post by: jmpessoa on May 06, 2015, 05:35:23 pm
@ rx3.fireproof

Quote
......I posted my app in Yandex.store :D

Congratulations!!!!!

Code: [Select]
....The form is destroyed, but not created again. If it possible, show an example code.

Ok I Will try some example code!

Thank you!


@greenzyzyzy

Quote
...how to use Android Module Wizard  to run a command line which in /system/bin ?

What you need? I can try ... but I do not know if we can run it in android without "root it"!

three comments:
1. There is a more updated "readme.txt"
2. Threre are two Lamw Applications Model [GUI and NoGui]
3. You can do a simple button click "hello world" [GUI] application with Lamw?

Thank you!

Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 07, 2015, 04:08:12 pm
@ rx3.fireproof

Quote
......I posted my app in Yandex.store :D

Congratulations!!!!!

Code: [Select]
....The form is destroyed, but not created again. If it possible, show an example code.

Ok I Will try some example code!

Thank you!


@greenzyzyzy

Quote
...how to use Android Module Wizard  to run a command line which in /system/bin ?

What you need? I can try ... but I do not know if we can run it in android without "root it"!

three comments:
1. There is a more updated "readme.txt"
2. Threre are two Lamw Applications Model [GUI and NoGui]
3. You can do a simple button click "hello world" [GUI] application with Lamw?

Thank you!

thank you, but i slove the problem,it is a easy way to run command with asyncprocess unit.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 07, 2015, 05:23:54 pm
@greenzyzyzy

Code: [Select]
.... i slove the problem,it is a easy way to run command with asyncprocess unit.

Can you put here a simple example code.... ???

Thank you!

Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 08, 2015, 04:47:20 am
@greenzyzyzy

Code: [Select]
.... i slove the problem,it is a easy way to run command with asyncprocess unit.

Can you put here a simple example code.... ???

Thank you!


well ,it is easy,in laz4android code like this:

uses
.....,asyncprocess;

procedure Tform1.Button1Click(Sender: TObject);
var
  proc:asyncprocess.TAsyncProcess;
begin
proc:=asyncprocess.TAsyncProcess.Create(nil);
proc.Executable:='su';
proc.Parameters.Add('-c');
proc.Parameters.Add('chmod 777 /dev/graphics/fb0');
proc.Execute;
proc.Free;
end;
Title: Re: Android Module Wizard
Post by: jmpessoa on May 09, 2015, 07:00:17 am
Hi All!

There is an updated revision of Lamw/Lazarus Android Module Wizard

https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 23 - 09 May 2015 -

   NEW! 
      jShellCommand component <<---A suggestion and request @greenzyzyzy

   NEW! Demo AppExecuteShellCommandDemo1 [Eclipse Compatible Project]

   NEW! Android Manifest Editor:
      Lazarus IDE: "Project' --> "Project Option" --> "[Lamw] Android Manifest"
[Thanks to  @A.S.]

   IMPROVEMENTS! components visual design    [Thanks to @A.S.]

Thanks to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 09, 2015, 08:37:03 am
I hope you will update sms reading function soon  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 09, 2015, 08:51:57 am
@m4u_hoahoctro

Ok! I will do!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on May 10, 2015, 01:09:37 pm
@m4u_hoahoctro

Quote
I hope you will update sms reading function soon  :)

Done!

Lamw: Version 0.6 - rev. 24 - 10 May 2015 -

https://github.com/jmpessoa/lazandroidmodulewizard

   NEWS! 
      jAnalogClock component
      jDigitalClock component

   IMPROVED!
      jSMS Added new "Read" method // <<--- A suggestion and request by @m4u_hoahoctro
      jEditText Added new "AppendLn" method
      jTextView Added new "AppendLn" method

   NEWS!
      Demo AppClockDemo1 [Eclipse Compatible Project]
      Demo AppSMSDemo1 [Eclipse Compatible Project]

Thanks to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 10, 2015, 03:29:25 pm
great  8-)
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 10, 2015, 08:50:34 pm
Hello Jmpessoa

In the new version introduces the ability to destroy the form and free the memory?

The Jspinner does not fully work.  :'(
    
Impossible to put on the form the required number of components :'( :'( :'(

My main problem is not solved. :'( :'( :'( :'( :'( :'(

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on May 10, 2015, 09:26:35 pm
@rx3.fireproof

I think that all these problems are related to memory management ....

What about your "assets"? What about images files sizes?

example: In my tests jSpinner is OK for a huge entry!

OK, I'll see what I can improve!

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 11, 2015, 12:11:23 am
@Jmpessoa

Now made form (actsplah) with 6 jspinners and 30 jimageviews with images from assets and drawable (halfpast). 
In each jspinner  added on 10000 items. Everything works.

I have something wrong with the layout. Try to understand.

I made  test new project.

May be an error while upgrate code template with old version LAMN?

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on May 11, 2015, 01:00:30 am
@rx3.fireproof

Quote
...May be an error while upgrade code template with old version LAMW?

Yes, may be.....

You can try:

1. Upgrade Code templates: [*.lpr] and [*.java]

2. Run --> Clean up and Build

When prompt "Read error" [Unknown Property] just choice:  "Continue Loading" !!
[Now simulate any property change in component, i.e., tag = 1  and save the project]

3. Run --> [Lamw] Build Apk and Run      //<<---------- connect your device [usb] !

Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 12, 2015, 05:28:01 pm
I am having a problem with display00
In this image, I set Jtextview ( :
Postoanchor: raalignleft is true, raalignirght is true and ratorightof is true
but they dont' have same size when displayed
 :(
Title: Re: Android Module Wizard
Post by: jmpessoa on May 12, 2015, 06:02:05 pm
Hi m4u_hoahoctro,

Please, "*.zip" [or "*.rar"] your project and send me: jmpessoa(AT)hotmail(DOT)com

or put it in some online open drive.

I will try some solution....
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 13, 2015, 03:58:37 am
you need press 4x4 button

https://drive.google.com/file/d/0Bx3SDL5wwBBYejI1Q0NVazQwejQ/view?usp=sharing (https://drive.google.com/file/d/0Bx3SDL5wwBBYejI1Q0NVazQwejQ/view?usp=sharing)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 13, 2015, 05:00:34 am
Hi  m4u_hoahoctro,

Here is a modified "unit2.lfm"

Code: [Select]
object AndroidModule2: TAndroidModule2
  Left = 945
  Top = 48
  Width = 300
  Height = 600
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule2'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  OnJNIPrompt = AndroidModule2JNIPrompt
  object jTextView1: jTextView
    Left = 5
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView1Click
    Id = 3718151
  end
  object jTextView2: jTextView
    Left = 76
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'B'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView2Click
    Id = 9461189
  end
  object jTextView3: jTextView
    Left = 147
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView2
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'C'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView3Click
    Id = 6341291
  end
  object jTextView4: jTextView
    Left = 218
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView3
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop, rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'B'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView4Click
    Id = 5522042
  end
  object jTextView5: jTextView
    Left = 5
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView5Click
    Id = 7622216
  end
  object jTextView6: jTextView
    Left = 76
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView5
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView6Click
    Id = 8770245
  end
  object jTextView7: jTextView
    Left = 147
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView6
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView7Click
    Id = 7830331
  end
  object jTextView8: jTextView
    Left = 218
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView7
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView8Click
    Id = 1969942
  end
  object jTextView9: jTextView
    Left = 5
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView5
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView9Click
    Id = 2190527
  end
  object jTextView10: jTextView
    Left = 76
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView9
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView10Click
    Id = 4756362
  end
  object jTextView11: jTextView
    Left = 147
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView10
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView11Click
    Id = 2589130
  end
  object jTextView12: jTextView
    Left = 218
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView11
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView12Click
    Id = 0
  end
  object jTextView13: jTextView
    Left = 5
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView9
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView13Click
    Id = 1752964
  end
  object jTextView14: jTextView
    Left = 76
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView13
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView14Click
    Id = 15784
  end
  object jTextView15: jTextView
    Left = 147
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView14
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView15Click
    Id = 5912469
  end
  object jTextView16: jTextView
    Left = 218
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 245
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView15
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView16Click
    Id = 2866691
  end
  object jTextView17: jTextView
    Left = 98
    Top = 289
    Width = 103
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 10
    MarginBottom = 5
    Visible = True
    Anchor = jTextView15
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'The Answer:'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 9929159
  end
  object jButton1: jButton
    Left = 82
    Top = 330
    Width = 136
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView17
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Start'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    Id = 4885599
  end
  object jButton2: jButton
    Left = 82
    Top = 378
    Width = 136
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Surrender'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton2Click
    Id = 1744465
  end
  object jTextView18: jTextView
    Left = 216
    Top = 289
    Width = 61
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView17
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpWrapContent
    Text = '00 : 00'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrNavajoWhite
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 0
  end
  object jSpinner1: jSpinner
    Left = 8
    Top = 432
    Width = 287
    Height = 40
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jButton2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Items.Strings = (
      'Hi'
      'Hello'
      'Bye bye'
    )
    BackgroundColor = colbrDefault
    SelectedFontColor = colbrDefault
    DropListTextColor = colbrDefault
    DropListBackgroundColor = colbrDefault
    LastItemAsPrompt = False
    FontSize = 0
    Id = 7525840
  end
  object jTextView19: jTextView
    Left = 103
    Top = 487
    Width = 94
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jSpinner1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'Hello Baby'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrWhiteSmoke
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 0
  end
  object jTextFileManager1: jTextFileManager
    left = 40
    top = 152
  end
  object jTimer1: jTimer
    Enabled = False
    Interval = 1000
    OnTimer = jTimer1Timer
    left = 104
    top = 152
  end
end
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 13, 2015, 08:08:59 am
 :(

This is project modified:
https://drive.google.com/file/d/0Bx3SDL5wwBBYMVBCejdtZlRRX1k/view?usp=sharing (https://drive.google.com/file/d/0Bx3SDL5wwBBYMVBCejdtZlRRX1k/view?usp=sharing)

and it also has an error when I reopen project as below image
after updating new version of lamw, I get new error: you can see this video:https://drive.google.com/file/d/0Bx3SDL5wwBBYajRoTFJaM1poejQ/view?usp=sharing (https://drive.google.com/file/d/0Bx3SDL5wwBBYajRoTFJaM1poejQ/view?usp=sharing)
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 13, 2015, 02:51:31 pm
Hello Jmpessoa

My problem is not in the jspinner.  The problem in the jSqliteCursor.

This code works in  the procedure  AndroidModule1JNIPrompt  if rowCount<=5.


var
i, rowCount:integer;

jSqliteDataAccess1.Select('select * from mytable');

rowCount := jSqliteDataAccess1.Cursor.GetRowCount;

for i := 0 to rowCount - 1 do begin
      jSqliteDataAccess1.Cursor.MoveToPosition(i);
    //  jspinner1.Add(jSqliteDataAccess1.Cursor.GetValueAsString(2));
end;       



In other procedures is work  if rowCount near 100-150.

How to make that the code is worked?



With Respect

rx3.fireproof

Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 14, 2015, 07:11:33 am
Hi  m4u_hoahoctro,

Here is a modified "unit2.lfm"

Code: [Select]
object AndroidModule2: TAndroidModule2
  Left = 945
  Top = 48
  Width = 300
  Height = 600
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule2'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  OnJNIPrompt = AndroidModule2JNIPrompt
  object jTextView1: jTextView
    Left = 5
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView1Click
    Id = 3718151
  end
  object jTextView2: jTextView
    Left = 76
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'B'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView2Click
    Id = 9461189
  end
  object jTextView3: jTextView
    Left = 147
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView2
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'C'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView3Click
    Id = 6341291
  end
  object jTextView4: jTextView
    Left = 218
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView3
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop, rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'B'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView4Click
    Id = 5522042
  end
  object jTextView5: jTextView
    Left = 5
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView5Click
    Id = 7622216
  end
  object jTextView6: jTextView
    Left = 76
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView5
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView6Click
    Id = 8770245
  end
  object jTextView7: jTextView
    Left = 147
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView6
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView7Click
    Id = 7830331
  end
  object jTextView8: jTextView
    Left = 218
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView7
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView8Click
    Id = 1969942
  end
  object jTextView9: jTextView
    Left = 5
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView5
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView9Click
    Id = 2190527
  end
  object jTextView10: jTextView
    Left = 76
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView9
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView10Click
    Id = 4756362
  end
  object jTextView11: jTextView
    Left = 147
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView10
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView11Click
    Id = 2589130
  end
  object jTextView12: jTextView
    Left = 218
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView11
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView12Click
    Id = 0
  end
  object jTextView13: jTextView
    Left = 5
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView9
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView13Click
    Id = 1752964
  end
  object jTextView14: jTextView
    Left = 76
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView13
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView14Click
    Id = 15784
  end
  object jTextView15: jTextView
    Left = 147
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView14
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView15Click
    Id = 5912469
  end
  object jTextView16: jTextView
    Left = 218
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 245
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView15
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView16Click
    Id = 2866691
  end
  object jTextView17: jTextView
    Left = 98
    Top = 289
    Width = 103
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 10
    MarginBottom = 5
    Visible = True
    Anchor = jTextView15
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'The Answer:'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 9929159
  end
  object jButton1: jButton
    Left = 82
    Top = 330
    Width = 136
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView17
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Start'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    Id = 4885599
  end
  object jButton2: jButton
    Left = 82
    Top = 378
    Width = 136
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Surrender'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton2Click
    Id = 1744465
  end
  object jTextView18: jTextView
    Left = 216
    Top = 289
    Width = 61
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView17
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpWrapContent
    Text = '00 : 00'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrNavajoWhite
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 0
  end
  object jSpinner1: jSpinner
    Left = 8
    Top = 432
    Width = 287
    Height = 40
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jButton2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Items.Strings = (
      'Hi'
      'Hello'
      'Bye bye'
    )
    BackgroundColor = colbrDefault
    SelectedFontColor = colbrDefault
    DropListTextColor = colbrDefault
    DropListBackgroundColor = colbrDefault
    LastItemAsPrompt = False
    FontSize = 0
    Id = 7525840
  end
  object jTextView19: jTextView
    Left = 103
    Top = 487
    Width = 94
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jSpinner1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'Hello Baby'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrWhiteSmoke
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 0
  end
  object jTextFileManager1: jTextFileManager
    left = 40
    top = 152
  end
  object jTimer1: jTimer
    Enabled = False
    Interval = 1000
    OnTimer = jTimer1Timer
    left = 104
    top = 152
  end
end

why my build apk can not run?codes no problem,compile ok,build apk ok,but run app does not show any component,only a blank window.
Title: Re: Android Module Wizard
Post by: LoneVoice on May 14, 2015, 02:29:57 pm
Hi,

Is there a way to get position and size of a component? Right now Left/Top/Width/Height properties only return value from fields and not the real position of components in most cases.

I also tried to add component to form/custom dialog using code but failed. Can anyone show me a working example so I can study?

The last thing is we can change color of a button, but then we lost "touch effect" when touching it. Could this behavior be changed in future releases?

Thanks in advance.  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 14, 2015, 05:51:39 pm
Hi LoneVoice,

1.
Quote
...Is there a way to get position and size of a component? Right now Left/Top/Width/Height .

I will try later....

2.
Quote
...add component to form/custom dialog using code but failed

I will try later....

3.
Quote
...change color of a button, but then we lost "touch effect" when touching it

Solution:

Put a jPanel and  change its Backgroundcolor,  then configure [after put the button over it!]:
     
      LayoutParamWidth = lpWrapContent
      LayoutParamHeight = lpWrapContent

Now put a jButton over jPanel and configure:

      BackgroundColor = colbrDefault
      LayoutParamWidth = some value
      LayoutParamHeight = lpWrapContent
      PosRelativeToParent = [rpCenterInParent]
 
Thank you!
Title: Re: Android Module Wizard
Post by: LoneVoice on May 14, 2015, 06:17:24 pm
Hi jmpessoa,

Solution:

Put a jPanel and  change its Backgroundcolor,  then configure [after put the button over it!]:
     
      LayoutParamWidth = lpWrapContent
      LayoutParamHeight = lpWrapContent

Now put a jButton over jPanel and configure:

      BackgroundColor = colbrDefault
      LayoutParamWidth = some value
      LayoutParamHeight = lpWrapContent
      PosRelativeToParent = [rpCenterInParent]

Ops I forgot button itself is transparent by default so we just need to change color of component behind it, thanks!
Title: Re: Android Module Wizard
Post by: A.S. on May 14, 2015, 09:06:22 pm
greenzyzyzy, try to update .java files.
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 15, 2015, 05:19:59 am
greenzyzyzy, try to update .java files.

i have change to jdk 1.8.20,problem still not solved.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 15, 2015, 05:29:51 am
about my problem ?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 15, 2015, 05:40:44 am
@ greenzyzyzy

Quote
greenzyzyzy, try to update .java files.

Just about:

Lazarus IDE -->> Tools --> [Lamw] Android Module Wizard -->> Upgrade Code Templates [*.lpr, *.java]

@m4u_hoahoctro,

Ok I will try some solution!

Thanks to All!


Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 15, 2015, 11:29:15 am
@ greenzyzyzy

Quote
greenzyzyzy, try to update .java files.

Just about:

Lazarus IDE -->> Tools --> [Lamw] Android Module Wizard -->> Upgrade Code Templates [*.lpr, *.java]

@m4u_hoahoctro,

Ok I will try some solution!


i have tested,problem still exist.
Thanks to All!

i have tested,problem still exist.and i build apk file,always need build two times,first failed,second
ok.is this case the probolem?(build step is ide->run->build apk and run.)
Title: Re: Android Module Wizard
Post by: A.S. on May 15, 2015, 08:50:01 pm
greenzyzyzy, can you provide build log (copy from messages window)?
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 04:29:56 am
greenzyzyzy, can you provide build log (copy from messages window)?

first time build apk show error:

BUILD FAILED
E:\lazarusandroid\android-sdk\tools\ant\build.xml:720: The following error occurred while executing this line:
E:\lazarusandroid\android-sdk\tools\ant\build.xml:734: Compile failed; see the compiler error output for details.


second time build apk ok.
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 04:32:38 am
greenzyzyzy, can you provide build log (copy from messages window)?

another question.laz4android play a mp3 need what uses-permission?
see topice here:
http://forum.lazarus.freepascal.org/index.php/topic,28445.0.html (http://forum.lazarus.freepascal.org/index.php/topic,28445.0.html)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2015, 04:54:20 am
@greenzyzyzy

Quote
...laz4android play a mp3 need what uses-permission?

no special .... but if your file is in the sdcard you will need:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

NOTE: Lamw has jMediaPlayer component e a demo "AppTryCode2":

Code? just try:

Code: [Select]
     jMediaPlayer1.SetDataSource('pipershut2.mp3');  //from  .../assets...
     jMediaPlayer1.Prepare();
     jMediaPlayer1.Start();

Thank you!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 05:12:27 am
@greenzyzyzy

Quote
...laz4android play a mp3 need what uses-permission?

no special .... but if your file is in the sdcard you will need:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

NOTE: Lamw has jMediaPlayer component e a demo "AppTryCode2":

Code? just try:

Code: [Select]
     jMediaPlayer1.SetDataSource('pipershut2.mp3');  //from  .../assets...
     jMediaPlayer1.Prepare();
     jMediaPlayer1.Start();

Thank you!

i have add the permission,it seems still can not run.



code put here:


Code: [Select]
unit mediaplayer;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,jni,customdrawnint;
var
  jmediaplayer_class:jclass;
  jmediaplayer_jobject:jobject;
  create_id:jmethodid;
  setdatasource_id:jmethodid;
  prepare_id:jmethodid;
  start_id:jmethodid;
  release_id:jmethodid;
procedure media_create();
procedure SetDataSource(path: string);
procedure Prepare();
procedure Start();
procedure Release();


implementation
procedure media_create();
begin
 jmediaplayer_class:=javaEnvRef^^.FindClass(javaEnvRef,'android/media/MediaPlayer');

 create_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, '<init>', '()V');
 setdatasource_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'SetDataSource', '(Ljava/lang/String;)V');
 prepare_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Prepare', '()V');
 start_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Start', '()V');
 release_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Release', '()V');

 jmediaplayer_jobject:=javaEnvRef^^.NewObject(javaEnvRef,jmediaplayer_class,create_id);

end;


procedure SetDataSource(path: string);
var
  lParams: array[0..0] of jValue;
begin
 lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(path));
 javaEnvRef^^.CallVoidMethodA(javaEnvRef, jmediaplayer_jobject,setdatasource_id, @lParams[0]);
 javaEnvRef^^.DeleteLocalRef(javaEnvRef, lParams[0].l);

end;

procedure Prepare();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,prepare_id);
end;

procedure Start();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,start_id);
end;

procedure Release();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,release_id);
end;

end.
 
Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2015, 05:40:22 am
@greenzyzyzy,

You need know/discovery what is the path to your device sdcard ...  just "/sdcard" can not work for all devices .... in java: Environment.getExternalStorageDirectory()
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 16, 2015, 06:13:09 am
jmpessoa: my problem hasn't been solved :(
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 06:14:58 am
@greenzyzyzy,

You need know/discovery what is the path to your device sdcard ...  just "/sdcard" can not work for all devices .... in java: Environment.getExternalStorageDirectory()

just procedure media_create() can not run pass.



Code: [Select]
procedure media_create();
begin
 jmediaplayer_class:=javaEnvRef^^.FindClass(javaEnvRef,'android/media/MediaPlayer');

 create_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, '<init>', '()V');
 setdatasource_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'SetDataSource', '(Ljava/lang/String;)V');
 prepare_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Prepare', '()V');
 start_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Start', '()V');
 release_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Release', '()V');

 jmediaplayer_jobject:=javaEnvRef^^.NewObject(javaEnvRef,jmediaplayer_class,create_id);

end;


these codes can not run,but i don't know where is wrong?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2015, 06:59:44 am
@m4u_hoahoctro

1. Well, when you update your Lamw some code can not work....
because some component property was lost but:
no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"

2. At the moment Lamw Author "A.S." is doing a hard [and nice] work to improve form designer, so old project can have some layout impact [but just in design time!]

3. If you problem is just with jTextView17/jTextView18 , you can try:

jTextView17
Anchor = jTextView13

jTextView18
Anchor = jTextView17
PosRelativeToAnchor = [raToRightOf,raAlignBaseline]

@greenzyzyzy,
In fact, with this pure [and hard!] JNI approach to access java objects the things get very very complicated to Pascal [and Lazarus] ... 
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 16, 2015, 07:13:16 am
@jmpessoa,

Now I am having a trouble with jtextview and jimage, some jtextviews and jimages are dissappeared when I run apk file. I try to fix many times but it doesn't change :-\

Download my project, build and run it, you will see jtextviews (7,8,11,12,15,16) don't appear ( form2), and jimage (form3) doesn't show its image, althought I choosed layout for them and type Image index correctly  %)

My friend said this is a bug, Is he true ?

https://app.box.com/s/90qwkwfk117acz5cks99vsvnyd1ubghg (https://app.box.com/s/90qwkwfk117acz5cks99vsvnyd1ubghg)
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 07:25:58 am
@m4u_hoahoctro

1. Well, when you update your Lamw some code can not work....
because some component property was lost but:
no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"

2. At the moment Lamw Author "A.S." is doing a hard [and nice] work to improve form designer, so old project can have some layout impact [but just in design time!]

3. If you problem is just with jTextView17/jTextView18 , you can try:

jTextView17
Anchor = jTextView13

jTextView18
Anchor = jTextView17
PosRelativeToAnchor = [raToRightOf,raAlignBaseline]

@greenzyzyzy,
In fact, with this pure [and hard!] JNI approach to access java objects the things get very very complicated to Pascal [and Lazarus] ...


no idea to solve my code?would you like to help me to have a test with my codes?

Code: [Select]
unit mediaplayer;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,jni,customdrawnint;
var
  jmediaplayer_class:jclass;
  jmediaplayer_jobject:jobject;
  create_id:jmethodid;
  setdatasource_id:jmethodid;
  prepare_id:jmethodid;
  start_id:jmethodid;
  release_id:jmethodid;
procedure media_create();
procedure SetDataSource(path: string);
procedure Prepare();
procedure Start();
procedure Release();


implementation
procedure media_create();
begin
 jmediaplayer_class:=javaEnvRef^^.FindClass(javaEnvRef,'android/media/MediaPlayer');

 create_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, '<init>', '()V');
 setdatasource_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'SetDataSource', '(Ljava/lang/String;)V');
 prepare_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Prepare', '()V');
 start_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Start', '()V');
 release_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Release', '()V');

 jmediaplayer_jobject:=javaEnvRef^^.NewObject(javaEnvRef,jmediaplayer_class,create_id);

end;


procedure SetDataSource(path: string);
var
  lParams: array[0..0] of jValue;
begin
 lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(path));
 javaEnvRef^^.CallVoidMethodA(javaEnvRef, jmediaplayer_jobject,setdatasource_id, @lParams[0]);
 javaEnvRef^^.DeleteLocalRef(javaEnvRef, lParams[0].l);

end;

procedure Prepare();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,prepare_id);
end;

procedure Start();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,start_id);
end;

procedure Release();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,release_id);
end;

end.

Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2015, 07:35:50 am
@m4u_hoahoctro

Quote
1.jpg
image2,jpg
3.jpg
4.jpg
5.jpg

You can see  "image2,jpg" ..... fix it!

@greenzyzyzy
Quote
...would you like to help me to have a test with my codes?

Sorry... I can not seem!

but you can:

change "SetDataSource" to "setDataSource"
Prepare to "prepare" 
Start to "start"  etc....

Good Luck!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 09:43:23 am
@m4u_hoahoctro

Quote
1.jpg
image2,jpg
3.jpg
4.jpg
5.jpg

You can see  "image2,jpg" ..... fix it!

@greenzyzyzy
Quote
...would you like to help me to have a test with my codes?

Sorry... I can not seem!

but you can:

change "SetDataSource" to "setDataSource"
Prepare to "prepare" 
Start to "start"  etc....

Good Luck!


thank you for reply,media_create( ) procedure run pass.
but next procedure still can not run.

Code: [Select]
procedure SetDataSource(path: string);
var
  lParams: array[0..0] of jValue;
begin
 lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(path));
 javaEnvRef^^.CallVoidMethodA(javaEnvRef, jmediaplayer_jobject,setdatasource_id, @lParams[0]);
 javaEnvRef^^.DeleteLocalRef(javaEnvRef, lParams[0].l);

end;

procedure Prepare();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,prepare_id);
end;

procedure Start();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,start_id);
end;

procedure Release();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,release_id);
end;

end.

run these codes still halt.
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 16, 2015, 10:08:25 am
@m4u_hoahoctro

Quote
1.jpg
image2,jpg
3.jpg
4.jpg
5.jpg

You can see  "image2,jpg" ..... fix it!

@greenzyzyzy
Quote
...would you like to help me to have a test with my codes?

Sorry... I can not seem!

but you can:

change "SetDataSource" to "setDataSource"
Prepare to "prepare" 
Start to "start"  etc....

Good Luck!






change "SetDataSource" to "setDataSource"
Prepare to "prepare" 
Start to "start"  etc....

Good Luck!

if i write code like this that will ok:

Code: [Select]
procedure test();
var
  jmediaplayer_class:jclass;
  jmediaplayer_jobject:jobject;
  create_id:jmethodid;
  setdatasource_id:jmethodid;
  prepare_id:jmethodid;
  start_id:jmethodid;
  release_id:jmethodid;
  lParams: array[0..0] of jValue;
begin
  jmediaplayer_class:=javaEnvRef^^.FindClass(javaEnvRef,'android/media/MediaPlayer');

 create_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, '<init>', '()V');
 setdatasource_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'setDataSource', '(Ljava/lang/String;)V');
 prepare_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'prepare', '()V');
 start_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'start', '()V');
 release_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'release', '()V');

 jmediaplayer_jobject:=javaEnvRef^^.NewObject(javaEnvRef,jmediaplayer_class,create_id);


 //lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar('/sdcard/mybmp/alert.mp3'));
 lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar('/storage/sdcard0/mybmp/alert.mp3'));
 javaEnvRef^^.CallVoidMethodA(javaEnvRef, jmediaplayer_jobject,setdatasource_id, @lParams[0]);
 javaEnvRef^^.DeleteLocalRef(javaEnvRef, lParams[0].l);

 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,prepare_id);

 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,start_id);

 //javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,release_id);
end;


but if like this it will have error.:
Code: [Select]
procedure media_create();
begin
 jmediaplayer_class:=javaEnvRef^^.FindClass(javaEnvRef,'android/media/MediaPlayer');

 create_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, '<init>', '()V');
 setdatasource_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'setDataSource', '(Ljava/lang/String;)V');
 prepare_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'prepare', '()V');
 start_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'start', '()V');
 release_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'release', '()V');

 jmediaplayer_jobject:=javaEnvRef^^.NewObject(javaEnvRef,jmediaplayer_class,create_id);

end;


procedure SetDataSource(path: string);
var
  lParams: array[0..0] of jValue;
begin
 lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(path));
 javaEnvRef^^.CallVoidMethodA(javaEnvRef, jmediaplayer_jobject,setdatasource_id, @lParams[0]);
 javaEnvRef^^.DeleteLocalRef(javaEnvRef, lParams[0].l);

end;

procedure Prepare();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,prepare_id);
end;

procedure Start();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,start_id);
end;

procedure Release();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,release_id);
end;                       


is that means jni can not use golbal viriants?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 17, 2015, 07:36:55 am
Hi All

There is a new Lamw revision:

Version 0.6 - rev. 25 - 14 May 2015

ref. https://github.com/jmpessoa/lazandroidmodulewizard

   NEW! 
      jForm "ShowCustomMessage" method

   NEW!    
      Demo AppCustomShowMessageDemo1 [Eclipse Compatible Project]
               

   NEW!   New Menu entry: added support to configure project demos
      Lazarus IDE --> Tools --> [Lamw] Android Module Wizard --> Change Project [*.lpi] Ndk Path [Demos]

Thank to All!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 17, 2015, 01:54:05 pm
Hi All

There is a new Lamw revision:

Version 0.6 - rev. 25 - 14 May 2015

ref. https://github.com/jmpessoa/lazandroidmodulewizard

   NEW! 
      jForm "ShowCustomMessage" method

   NEW!    
      Demo AppCustomShowMessageDemo1 [Eclipse Compatible Project]
               

   NEW!   New Menu entry: added support to configure project demos
      Lazarus IDE --> Tools --> [Lamw] Android Module Wizard --> Change Project [*.lpi] Ndk Path [Demos]

Thank to All!

does laz4android threads can not support TBitmap?
just use beginthread or tthread class. it seems only support TBitmap some method
juse like loadfromstream,savetostream,loadfromfile,savetofile.
but use TBitmap.canvas or TBitmap.width,TBitmap.height property,application exit immediately.
no idea to use TBitmap in thread perfect?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 17, 2015, 05:55:48 pm
@greenzyzyzy,

Please, here on this thread we support

Lamw: Lazarus Android Module Wizard

ref. https://github.com/jmpessoa/lazandroidmodulewizard

I hope your understanding...

Thank you!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 18, 2015, 05:05:36 am
@greenzyzyzy,

Please, here on this thread we support

Lamw: Lazarus Android Module Wizard

ref. https://github.com/jmpessoa/lazandroidmodulewizard

I hope your understanding...

Thank you!

thanks for reply,but it seems not support all tbitmap method in thread with cthreads unit.Does  Lazarus Android Module Wizard support?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 18, 2015, 05:52:35 am
@ greenzyzyzy,

Lamw has native jBitmap, native jImageFileManager, native jImageView and native jAsynTask....

You can try some demos apps....

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 18, 2015, 02:02:05 pm
Hello Jmpessoa

In the latest version, the jScrollView does not work.
     
(If it contains other components)


With Respect

rx3.fireproof

Title: Re: Android Module Wizard
Post by: jmpessoa on May 18, 2015, 11:52:00 pm
@ rx3.fireproof

Quote
....In the latest version, the jScrollView does not work.

Ok, FIXED !!!!

Thank you very much!!!!
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 19, 2015, 05:57:46 am
@ greenzyzyzy,

Lamw has native jBitmap, native jImageFileManager, native jImageView and native jAsynTask....

You can try some demos apps....

Thank you!

thank you very much.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 19, 2015, 04:58:27 pm
Does anyone use genymotion ? I drag and drop my apk file to virtual device window, but it shows a dialog: Unfortunately, walle has stopped.
I tried searching some ways, but there are not many ways can fix
:(
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 19, 2015, 09:41:42 pm
Hello Jmpessoa

The jScrollView does not work fully. If I send the unit and form with drawable by email, You can see why it doesn't work. If you do not use the jScrollView, it works, but I need scrolling.

On 0.6.23 this form is worked as actsplash.


With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on May 19, 2015, 10:20:31 pm
@rx3.fireproof

Quote
....I need scrolling...

Try change/increase the value of "ScrollSize" property ... the default is "800"

Thank you!

P.S Today [later] I will fix "jHorizontalScroolView"! Wait!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 20, 2015, 06:21:03 am
impessoa. Plese help me modify my project.Try many times but I can't margin controls on form
Download it here:
https://app.box.com/s/90qwkwfk117acz5cks99vsvnyd1ubghg (https://app.box.com/s/90qwkwfk117acz5cks99vsvnyd1ubghg)

 :-\

Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 22, 2015, 12:12:42 pm
Hello Jmpessoa

The jScrollView does not work fully.


With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2015, 06:56:17 pm
Hi All

There is an updated "Lamw/Lazaru Android Module Wizard"   revision!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 26 - 21 May 2015 -

   NEW! 
      jTCPSocketClient component

   FIXED!    
      jHorizontalScrollView component
   NEW! 
      Demo AppHorizontalScrollViewDemo1 [Eclipse Compatible Project]
      Demo AppTCPClientDemo1 [Eclipse Compatible Project]

Thanks to All!

PS.

@rx3.fireproof,  the "AppHorizontalScrollViewDemo1" is too a jScrollView demo!

and it is working!!!

Possible causes of your problem:

1. Old revision, before the bug fixed [18, 2015, 08]!
2. Property "ScrollSize" is smal
3. Visual designer trick: After put your jScrollView content, as the last action,  you need set
the appropriate "LayoutParamHeight" property [by designer!].
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 22, 2015, 07:48:52 pm
 @Jmpessoa

Non-working example.

https://yadi.sk/d/ppVq7KGdgp27G

It will work:

- If I remove any one jeditortext or jtextview;

- If I will set the property fontsize to zero for all jeditortext and jtextview;

- I will not change the  property text for all jeditortext and jtextview in JNIPrompt procedure.

    
In all other cases, the application does not start.

Please find the error.
 
Sorry, but for me now jScrollView in 06.26 does not work.
 

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2015, 08:29:49 pm
@rx3.fireproof

Ok, now I understand! news issues!

I will try some solutions!

Thank you!

@m4u_hoahoctro

Please, try "jGridView",  there is a demo app....
Title: Re: Android Module Wizard
Post by: euller on May 22, 2015, 08:46:03 pm
I tried to make my own example here using jShellCommand and nothing. The application builds and installs all right, but when it tries to run, a white screen appears and a warning from android, saying that the application has stopped working, just remove this component of the application that it works right, does anyone could tell me why this happens?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2015, 09:30:53 pm
@euller

Please,

Put your [.zip] app in some open drive  or send it to: jmpessoaAThotmailDOTcom ...

Thank you!
 
Title: Re: Android Module Wizard
Post by: euller on May 22, 2015, 10:00:20 pm
Done, thank you in advance for your help.
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 22, 2015, 10:55:36 pm
 @Jmpessoa

I added to the archive working app.
https://yadi.sk/d/ppVq7KGdgp27G
    
Folder  "it_works_1"  with   property fontsize=0.
Folder  "it_works_2"  when   removed one jedittext (jedittext2).

Maybe this will help find the error.


With Respect

rx3.fireproof


Title: Re: Android Module Wizard
Post by: jmpessoa on May 23, 2015, 08:30:31 am
Hi All!

Thanks to  @rx3.fireproof, 

I  fixed an important "JNI ERROR (app bug): local reference table overflow"

Please, update you Lamw!!!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Hi rx3.fireproof!

I think now your memory management problems are solved!

Your nice App is running again!  :D :D :D  :-[ [Attachment]
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 23, 2015, 04:13:14 pm
Now i can't add new procedure to app
when compiling, it show message : unit2.pas(77,15) Error: Forward declaration not solved "khoitao;"
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 23, 2015, 05:37:35 pm
Hi All!

Thanks to  @rx3.fireproof, 

I  fixed an important "JNI ERROR (app bug): local reference table overflow"

Please, update you Lamw!!!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Hi rx3.fireproof!

I think now your memory management problems are solved!

Your nice App is running again!  :D :D :D  :-[ [Attachment]

hello jmpessoa ,
would you like to teach me how to pass a jstring array to a jvalue?
can i do it like this?


var
javaString:array [0..2]of jstring;
lParams: array[0..0] of JValue;
........
........
begin
  javaString[0]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'http://magnifier.sourceforge.net');
  javaString[1]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus');
  javaString[2]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus-ide');
lParams[0].l:=javaString;
...
end;
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 23, 2015, 10:30:22 pm
Hello Jmpessoa


I checked the latest fixes. Everything works fine.

Thank you very much.


With Respect

rx3.fireproof


ps

I will try to do a more complex form.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 24, 2015, 02:23:39 am
@rx3.fireproof,

Quote
would you like to teach me how to pass a jstring array to a jvalue?
can i do it like this?

var
javaString:array [0..2]of jstring;
lParams: array[0..0] of JValue;
........
........
begin
  javaString[0]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'http://magnifier.sourceforge.net');
  javaString[1]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus');
  javaString[2]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus-ide');
lParams[0].l:=javaString;
...
end;

There is a tutorial about string array [and others...]: "MyHello.pas" and the wrapper/counterparty "class jMyHello" in "Controls.java" !!

Demo: jMyHello component and app "AppTryCode1"

Minor diference:

We use "And_jni.pas" not "jni.pas", so we write:

"Env^.NewStringUTF(javaEnvRef, 'lazarus-ide');"

not   "Env^^NewStringUTF(javaEnvRef, 'lazarus-ide');"

etc...

But if you have a more specific need/requirement, please, put it here  ....


Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 25, 2015, 06:09:18 am
how can I load an image from sd card and show to form ?
@ jmpessoa: please help me about before problem that I asked  :-X
Title: Re: Android Module Wizard
Post by: jmpessoa on May 25, 2015, 11:56:29 pm
Hi m4u_hoahoctro!

You can try:

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  jimage1: jObject;     
begin 
    jimage:= jImageFileManager1.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirSdCard),'image1.png');
    jImageView1.SetImageBitmap(jimage1);
end;

There is a demo "AppShareFileDemo1", you can see others codes too....
Title: Re: Android Module Wizard
Post by: greenzyzyzy on May 26, 2015, 05:45:22 am
@rx3.fireproof,

Quote
would you like to teach me how to pass a jstring array to a jvalue?
can i do it like this?

var
javaString:array [0..2]of jstring;
lParams: array[0..0] of JValue;
........
........
begin
  javaString[0]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'http://magnifier.sourceforge.net');
  javaString[1]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus');
  javaString[2]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus-ide');
lParams[0].l:=javaString;
...
end;

There is a tutorial about string array [and others...]: "MyHello.pas" and the wrapper/counterparty "class jMyHello" in "Controls.java" !!

Demo: jMyHello component and app "AppTryCode1"

Minor diference:

We use "And_jni.pas" not "jni.pas", so we write:

"Env^.NewStringUTF(javaEnvRef, 'lazarus-ide');"

not   "Env^^NewStringUTF(javaEnvRef, 'lazarus-ide');"

etc...

But if you have a more specific need/requirement, please, put it here  ....


thank you very much.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 26, 2015, 06:14:25 am
Hi m4u_hoahoctro!

You can try:

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  jimage1: jObject;     
begin 
    jimage:= jImageFileManager1.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirSdCard),'image1.png');
    jImageView1.SetImageBitmap(jimage1);
end;

There is a demo "AppShareFileDemo1", you can see others codes too....

thanks, but now: I can't add any procedure. It shows error:foward declaraction not solved
Title: Re: Android Module Wizard
Post by: jmpessoa on May 26, 2015, 07:23:35 pm
@ m4u_hoahoctro

Quote
...I can't add any procedure. It shows error:foward declaraction not solved

Where ? Please, put your code here.....
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 27, 2015, 05:22:01 pm
@ m4u_hoahoctro

Quote
...I can't add any procedure. It shows error:foward declaraction not solved

Where ? Please, put your code here.....

ok I will post code later  :)
hmm, I still have a question :-[: how do make a menu that subs menu can link to a procedure in program ?

and, seems be jmediaplayer can't open film file ?, I tried and it did't work  :'( ( example: mp4.mkv)
Title: Re: Android Module Wizard
Post by: jmpessoa on June 02, 2015, 05:02:46 pm
Hi All!

There is an updated "Lamw/Lazarus Android Module Wizard" revision!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 28 - 02 June 2015

   NEW!
      jForm "TakeScreenshot" method
      jForm "Vibrate" method
         :"AndroidManifest.xml" add on: 
            "<uses-permission android:name="android.permission.VIBRATE"/>"
   IMPROVEDMENTS!   
      jAsyncTask component:
         New! component design/behaviour  changed!
         News events properties:
                OnDoInBackground
            OnProgressUpdate
            OnPreExecute
            OnPostExecute

         ::Redesigned Demo : AppAsyncTaskDemo1             

      jHttpClient
         New! Added build in "asynctask" support!
         News events properties:
            OnContentResult
            OnCodeResult

         ::Redesigned Demo: AppHttpClientDemo1               
   
      jDialogProgress component //<--- Euller's suggestion!
         New! Added "custom view" support!
         News methods:                        
            Show
                            Close
            SetMessage
            SetTitle
            SetCancelable
   NEW! 
      Demo AppDialogProgressDemo1 [Eclipse Compatible Project]          

Thank to All!
Title: Re: Android Module Wizard
Post by: renabor on June 03, 2015, 04:03:31 pm
Hello Jmpessoa
I have upgraded to latest version (rev. 28) but jHttpClient works no more.
I get this error:

java.lang.NoSuchMethodError: no method with name='Get' signature='(Ljava/lang/String;)V' in class Lcom/suevoz/hello/jHttpClient;

consider that the code is just the same that was working fine with rev. 27, with the only difference that now I'm using jHttpClient1ContentResult for retrieving the result of the Http request.

Any idea?

with respect
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 03, 2015, 05:23:18 pm
I have some errors when compiling project:
controls.lpr(231,3) Error: Identifier not found "Java_Event_pOnAsyncEvent"

Panic: tool stopped with exit code 1. Use context menu to get more information.

Fatal: [Exception] Failed: Cannot build APK!

Link of my project: https://drive.google.com/file/d/0Bx3SDL5wwBBYaHAxVVJhNUxwaXM/view?usp=sharing
Title: Re: Android Module Wizard
Post by: jmpessoa on June 03, 2015, 06:49:02 pm
@m4u_hoahoctro

@renabor

Yes, we did dramatic changes, sorry!

Please, you can learn the new components design/behaviour in the Demos:  AppAsyncTaskDemo1 and AppHttpClientDemo1  !!!

1. jAsyncTask lost property "OnAsyncEvent" but no panic!
when prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Now copy the old code to matching/equivalent news events:
           OnDoInBackground
            OnProgressUpdate
            OnPreExecute
            OnPostExecute

2. jHttpClient: now "runInBackground/asynctask" have build in  support! You do not  need more use jAsyncTask component to run it "in background" !

ok, you will need handle the new event "ContentResult" to get content result and
"get" now is a procedure [not a function] ... so, no more result!

Again, sorry ...

but, the changes was for more elegance and effective solution! 

Thanks to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 04, 2015, 02:02:03 am
@m4u_hoahoctro

@renabor

Yes, we did dramatic changes, sorry!

Please, you can learn the new components design/behaviour in the Demos:  AppAsyncTaskDemo1 and AppHttpClientDemo1  !!!

1. jAsyncTask lost property "OnAsyncEvent" but no panic!
when prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Now copy the old code to matching/equivalent news events:
           OnDoInBackground
            OnProgressUpdate
            OnPreExecute
            OnPostExecute


can you explain more ? . copy old code ? I don't know how to find them ?  :-\

about error:

Identifier not found "Java_Event_pOnAsyncEvent"

and

Can't build apk file (If I create new project )

Sorry because I haven't understand your meaning yet  :-\
Title: Re: Android Module Wizard
Post by: jmpessoa on June 04, 2015, 03:32:21 am
@m4u_hoahoctro

QUESTION 1

Quote
about error:
....Identifier not found "Java_Event_pOnAsyncEvent"

solution: you need upgrade you project  code  templates .... [need by new revision]

Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

QUESTION 2

Quote
....copy old code ?

meaning [just example]:

Code: [Select]
case EventType of:

atsBefore: begin
                      // <------------ old code here! copy to new "OnPreExecute"
                 end;

atsInBackground: begin
                                  //<------------ old code here! copy to new "OnDoInBackground"
                             end;

atsProgress: begin
                          // <------------ old code here! copy to new " OnProgressUpdate"
                     end;

atsPost: begin
                    // <------------ old code here! copy to new "OnPostExecute"
              end;
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 04, 2015, 10:19:24 am
@m4u_hoahoctro

QUESTION 1

Quote
about error:
....Identifier not found "Java_Event_pOnAsyncEvent"

solution: you need upgrade you project  code  templates .... [need by new revision]

Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]


thanks much  :)

in demos about internet and socket, it seems not to say about how to get content of a website ( then save to tstringlist ), just about web browser and get url of site, so
how to do that ?  :D
Title: Re: Android Module Wizard
Post by: renabor on June 04, 2015, 03:34:39 pm
Hello jmpessoa,
I've resolved my problem creating a new project and copying all unit files to the new location.
Have you in plan to implement https and/or OAuth protocol?

thank you very much for your patience and your great job!
Title: Re: Android Module Wizard
Post by: jmpessoa on June 04, 2015, 05:25:33 pm
@m4u_hoahoctro

Quote
..... how to get content of a website ( then save to tstringlist )....

Code: [Select]
procedure TAndroidModule1.jHttpClient1ContentResult(Sender: TObject; content: string);
var
   myList: TStringList;
begin
  myList:= TStringList.Create;
  myList.Text:= content;
  myList.SaveToFile(self.GetEnvironmentDirectoryPath(dirDownloads), 'mycontent.txt');
  myList.Free;
end;

Quote
  ....jmediaplayer can't open film file ?

Ok,  I'm improving it!


 @renabor

Quote
... Have you in plan to implement https and/or OAuth protocol?

I will search and try some implementation...


Thanks to All
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 05, 2015, 11:40:09 am
thanks much jmpessoa   :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 06, 2015, 03:46:43 pm
Today I tested bluetooth app again, I used your code in BluetoothAppDemos

Quote
var jimage:jobject;
   copyOk:boolean;
begin
  jimage:= jImageFileManager1.LoadFromAssets('picture.jpg');

   //save to internal app storage...
  jImageFileManager1.SaveToFile(jimage, 'picture.jpg');

  //copy from internal storage  to /downloads [public directory!]
  copyOk:= Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirInternalAppStorage)+'/picture.jpg',
                        Self.GetEnvironmentDirectoryPath(dirDownloads)+'/picture.jpg');

   //_mimetype [lowercase!]:  "image/jpeg" or "text/plain" or "image/*" or "*/*" etc...
   if copyOk then
      jBluetooth1.SendFile(Self.GetEnvironmentDirectoryPath(dirDownloads),'picture.jpg', 'image/*');
end;                             

After press button, my app closes and show notification: The application process org.laz.gin2 has stopped unexpectedly. Please try again

I am thinking about lamw no longer supports bluetooth connection on andr 2.3  although If i use jsharefile, it still can work  :o
Title: Re: Android Module Wizard
Post by: euller on June 06, 2015, 04:13:59 pm
Today I tested bluetooth app again, I used your code in BluetoothAppDemos

Quote
var jimage:jobject;
   copyOk:boolean;
begin
  jimage:= jImageFileManager1.LoadFromAssets('picture.jpg');

   //save to internal app storage...
  jImageFileManager1.SaveToFile(jimage, 'picture.jpg');

  //copy from internal storage  to /downloads [public directory!]
  copyOk:= Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirInternalAppStorage)+'/picture.jpg',
                        Self.GetEnvironmentDirectoryPath(dirDownloads)+'/picture.jpg');

   //_mimetype [lowercase!]:  "image/jpeg" or "text/plain" or "image/*" or "*/*" etc...
   if copyOk then
      jBluetooth1.SendFile(Self.GetEnvironmentDirectoryPath(dirDownloads),'picture.jpg', 'image/*');
end;                             

After press button, my app closes and show notification: The application process org.laz.gin2 has stopped unexpectedly. Please try again

I am thinking about lamw no longer supports bluetooth connection on andr 2.3  although If i use jsharefile, it still can work  :o


@m4u_hoahoctro: the bluetooth components are partially functional, if you see this https://github.com/jmpessoa/lazandroidmodulewizard/issues/19 (https://github.com/jmpessoa/lazandroidmodulewizard/issues/19), you will know what I'm talking about. Right now, I'm experimenting with the components, to see if I can implement these functionalities, but I'm not making promises that they will work, or be reliable, I can only promise that I will try to make it happens.

P.S.: I tried using on the APIs 15, 16, 17, 19 and 22, and I didn't see what you've described.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 07, 2015, 01:49:02 am
Today I tested bluetooth app again, I used your code in BluetoothAppDemos

Quote
var jimage:jobject;
   copyOk:boolean;
begin
  jimage:= jImageFileManager1.LoadFromAssets('picture.jpg');

   //save to internal app storage...
  jImageFileManager1.SaveToFile(jimage, 'picture.jpg');

  //copy from internal storage  to /downloads [public directory!]
  copyOk:= Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirInternalAppStorage)+'/picture.jpg',
                        Self.GetEnvironmentDirectoryPath(dirDownloads)+'/picture.jpg');

   //_mimetype [lowercase!]:  "image/jpeg" or "text/plain" or "image/*" or "*/*" etc...
   if copyOk then
      jBluetooth1.SendFile(Self.GetEnvironmentDirectoryPath(dirDownloads),'picture.jpg', 'image/*');
end;                             

After press button, my app closes and show notification: The application process org.laz.gin2 has stopped unexpectedly. Please try again

I am thinking about lamw no longer supports bluetooth connection on andr 2.3  although If i use jsharefile, it still can work  :o


@m4u_hoahoctro: the bluetooth components are partially functional, if you see this https://github.com/jmpessoa/lazandroidmodulewizard/issues/19 (https://github.com/jmpessoa/lazandroidmodulewizard/issues/19), you will know what I'm talking about. Right now, I'm experimenting with the components, to see if I can implement these functionalities, but I'm not making promises that they will work, or be reliable, I can only promise that I will try to make it happens.

P.S.: I tried using on the APIs 15, 16, 17, 19 and 22, and I didn't see what you've described.

may be it doesn't support android 2.3, thanks for your answer  :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 07, 2015, 04:46:31 pm
@jmpessoa

I created a browser from your demo (Demo1-Webcontrol ), and when I press button to navigate google.com ( or another link), webpage not available ( I tested on virtual and real device, but result same as )

compiler also show error: not defind 'self.updatelayout', commands about self.* still work if I don't use jwebview

this is project:

https://app.box.com/s/a171qc4clw47guulhbrhrbc4n0ijk95v (https://app.box.com/s/a171qc4clw47guulhbrhrbc4n0ijk95v)

So what did I miss ?  :o
Title: Re: Android Module Wizard
Post by: jmpessoa on June 10, 2015, 07:35:08 am
Hi All!

There is a new Lamw/Lazarus Android Module Wizard revision !!

ref.    https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 29 - 08 June 2015 -

   NEW!

               jSurfaceView component

   IMPROVEDMENTS!   

      jMediaPlayer component:         
         New! Added support to video play! // <<- @m4u_hoahoctro's request

   NEW! 

      Demo AppMediaPlayerDemo1 [Eclipse Compatible Project]          
      Demo AppSurfaceViewDemo1 [Eclipse Compatible Project]

   UPDATED: All Demos was "upgrade"!         

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Thanks to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 10, 2015, 04:17:08 pm
@jmpessoa, I haven't had any knowledges about web programming yet, so although I tried to read your examples to write an web application, but it seems not be easy  %)

if you have free time, would you mind helping me write an web application that can read text data on a website ( example: read this text and save to string from my site here: http://cartoonforyou.forumvi.com/h1-page)

I also have some problems with jwebview as I replied above

thanks much  :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 10, 2015, 05:46:55 pm
Hi All!

There is a new Lamw/Lazarus Android Module Wizard revision !!

ref.    https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 29 - 08 June 2015 -

   NEW!

               jSurfaceView component

   IMPROVEDMENTS!   

      jMediaPlayer component:         
         New! Added support to video play! // <<- @m4u_hoahoctro's request

   NEW! 

      Demo AppMediaPlayerDemo1 [Eclipse Compatible Project]          
      Demo AppSurfaceViewDemo1 [Eclipse Compatible Project]

   UPDATED: All Demos was "upgrade"!         

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Thanks to All!

I updated my project, but seems to have an error with jmediaplayer, can't play mp3 or mp4 files as before, I must reuse old version of lamw  :(
Title: Re: Android Module Wizard
Post by: euller on June 11, 2015, 03:05:50 pm
@m4u_hoahoctro: the bluetooth components are partially functional, if you see this https://github.com/jmpessoa/lazandroidmodulewizard/issues/19 (https://github.com/jmpessoa/lazandroidmodulewizard/issues/19), you will know what I'm talking about. Right now, I'm experimenting with the components, to see if I can implement these functionalities, but I'm not making promises that they will work, or be reliable, I can only promise that I will try to make it happens.

P.S.: I tried using on the APIs 15, 16, 17, 19 and 22, and I didn't see what you've described.

Well, I tried to do by myself, and failed miserably. I don't know the why, I used code that worked on other application and nothing. Every time I tested the new component with the modified functionalities, the application didn't even start properly. For now, I'm gonna put this on pause, but I will return to it briefly.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 12, 2015, 12:07:17 am
@euller

Quote
... For now, I'm gonna put this on pause

Ok, I also had to do this to avoid delaying the project ...  but I will return in the weekend ...let's see what I can do

@ m4u_hoahoctro

Ok I will do a new demo....
Title: Re: Android Module Wizard
Post by: jmpessoa on June 12, 2015, 06:56:21 am
@ m4u_hoahoctro

here is a simple HttpClient and WebView demo ....

https://jmpessoa.opendrive.com/files?Ml85MDM4MzUyNV9lS2ZMTw

or you can create a new project and replace yours  "unit1.pas" and "unit1.lfm" by these:

unit1.pas [demo code ]
Code: [Select]

unit unit1;
 
{$mode delphi}
 
interface
 
uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget, textfilemanager;
 
type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
      jButton1: jButton;
      jEditText1: jEditText;
      jEditText2: jEditText;
      jHttpClient1: jHttpClient;
      jTextFileManager1: jTextFileManager;
      jTextView1: jTextView;
      jTextView2: jTextView;
      jWebView1: jWebView;
      procedure AndroidModule1JNIPrompt(Sender: TObject);
      procedure AndroidModule1Rotate(Sender: TObject; rotate: integer;
        var rstRotate: integer);
      procedure jButton1Click(Sender: TObject);
      procedure jHttpClient1CodeResult(Sender: TObject; code: integer);
      procedure jHttpClient1ContentResult(Sender: TObject; content: string);

    private
      {private declarations}
    public
      {public declarations}
  end;
 
var
  AndroidModule1: TAndroidModule1;

implementation
 
{$R *.lfm}

{ TAndroidModule1 }

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
  jEditText2.Clear;
  jHttpClient1.Get(jEditText1.Text);    //get content  ... http://cartoonforyou.forumvi.com/h1-page
  jWebView1.Navigate('http://www.freepascal.org');  // view web page  ... or: http://cartoonforyou.forumvi.com/h1-page
end;

procedure TAndroidModule1.jHttpClient1CodeResult(Sender: TObject; code: integer);
begin
   ShowMessage(IntToStr(code));
end;

procedure TAndroidModule1.jHttpClient1ContentResult(Sender: TObject; content: string);
var
  list: TStringList;
  txtContent: String;
  ok: boolean;
begin

  jEditText2.AppendLn(content);

  //save to device folder Download...   you can try others folders
  list:= TStringList.Create;
  list.Text:= content;
  list.SaveToFile(Self.GetEnvironmentDirectoryPath(dirDownloads)+'/mycontent.txt');
  list.Free;

   //test  [is it there ?]
   txtContent:=  jTextFileManager1.LoadFromFile( Self.GetEnvironmentDirectoryPath(dirDownloads), 'mycontent.txt');
   ShowMessage(txtContent);   //yes, it is !!!!

  //others test ....
  {ok:= Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirDownloads) + '/mycontent.txt',
                      Self.GetEnvironmentDirectoryPath(dirSdCard) + '/mycontent.txt');

   if ok then ShowMessage('copied !!') else  ShowMessage('copy  fail!')
  }

end;

procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
  jEditText2.Clear;
  jEditText1.SetFocus;

  if  not Self.IsWifiEnabled() then Self.SetWifiEnabled(True);

  //Test
  {if Self.IsSdCardMounted then ShowMessage('Yes, SdCard is Mounted!!!')
   else ShowMessage('Warning, SdCard is NOT Mounted!');
  }
end;

procedure TAndroidModule1.AndroidModule1Rotate(Sender: TObject;
  rotate: integer; var rstRotate: integer);
begin
   Self.UpdateLayout;
end;

end.



unit1.lfm  [demo code]
Code: [Select]
object AndroidModule1: TAndroidModule1
  Left = 339
  Top = 80
  Width = 300
  Height = 600
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule1'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  OnRotate = AndroidModule1Rotate
  OnJNIPrompt = AndroidModule1JNIPrompt
  object jTextView1: jTextView
    Left = 46
    Top = 5
    Width = 208
    Height = 20
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'App HttpClient and WebView Demo'
    Alignment = taLeft
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    TextTypeFace = tfNormal
    Id = 1806969
  end
  object jEditText1: jEditText
    Left = 5
    Top = 70
    Width = 290
    Height = 39
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jTextView2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Text = 'http://cartoonforyou.forumvi.com/h1-page'
    Alignment = taLeft
    InputTypeEx = itxText
    MaxTextLength = 300
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    HintTextColor = colbrSilver
    ScrollBarStyle = scrNone
    MaxLines = 1
    HorScrollBar = True
    VerScrollBar = False
    WrappingLine = False
    Editable = True
    Id = 5407544
  end
  object jTextView2: jTextView
    Left = 5
    Top = 35
    Width = 20
    Height = 20
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'Url:'
    Alignment = taLeft
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    TextTypeFace = tfNormal
    Id = 313328
  end
  object jEditText2: jEditText
    Left = 5
    Top = 177
    Width = 290
    Height = 106
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpOneFifthOfParent
    Text = 'jEditText2'
    Alignment = taLeft
    InputTypeEx = itxMultiLine
    MaxTextLength = 2000
    BackgroundColor = colbrPeachPuff
    FontColor = colbrDefault
    FontSize = 0
    HintTextColor = colbrSilver
    ScrollBarStyle = scrNone
    MaxLines = 20
    HorScrollBar = True
    VerScrollBar = True
    WrappingLine = False
    Editable = True
    Id = 3379671
  end
  object jButton1: jButton
    Left = 2
    Top = 123
    Width = 296
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jEditText1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Text = 'Get Url Content'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    Id = 2166001
  end
  object jWebView1: jWebView
    Left = 8
    Top = 296
    Width = 280
    Height = 280
    Visible = True
    Anchor = jEditText2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpHalfOfParent
    JavaScript = True
    BackgroundColor = colbrDefault
    ZoomControl = False
    Id = 0
  end
  object jHttpClient1: jHttpClient
    IndexUrl = -1
    AuthenticationMode = autNone
    OnContentResult = jHttpClient1ContentResult
    OnCodeResult = jHttpClient1CodeResult
    left = 128
    top = 208
  end
  object jTextFileManager1: jTextFileManager
    left = 224
    top = 208
  end
end
Title: Re: Android Module Wizard
Post by: renabor on June 12, 2015, 08:36:54 am
Hi @jmpessoa,

I have a problem with the Id of the objects.
Any new object inserted in a form get an Id of 0, with the conseguence that you can imagine. Is it possible to automate the generation of a unique Id for the newly created object?
I use Lazarus Ide under linux.

Which is the correct way to work with jHttpClient authentication, I have tried this code but without positiv results:

      jHttpClient1.SetAuthenticationHost('http://192.168.1.16',80);
      jHttpClient1.SetAuthenticationUser('username', 'password');
      jHttpClient1.AuthenticationMode:=autBasic;
      jHttpClient1.Get('http://192.168.1.16');

and so, what is wrong?
Can you extend the jHttpClient Class implementing the UPDATE and DELETE methods?

Another question about menu.
I have many Forms in my app and I need different menu in each form, how can I achieve this result?
I use intensely jSqlLite and jHttpClient in any form of my app but I'm unable to share the first instance so I recreate it in every new form. Is there a way to improve it?
Can you suggest me a method to access Contacts for reading and writing them?

thank you very much!

Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 12, 2015, 11:39:06 am
@ m4u_hoahoctro

here is a simple HttpClient and WebView demo ....

https://jmpessoa.opendrive.com/files?Ml85MDM4MzUyNV9lS2ZMTw


@jmpesssoa : thanks much  :D , now I feel if I want my app can connect to hosting and update, may be I must use SQL, so I will research about it  :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 12, 2015, 03:19:32 pm
@jmpessoa, I do a mediaplayer app using jsurface to play film file, but it show message: The end when I click on Play button ( checked radiobutton "Video" )

this is it, please test if I miss something

https://drive.google.com/file/d/0Bx3SDL5wwBBYTUFnMHBCWE0xQmM/view?usp=sharing (https://drive.google.com/file/d/0Bx3SDL5wwBBYTUFnMHBCWE0xQmM/view?usp=sharing)
 
thanks
Title: Re: Android Module Wizard
Post by: jmpessoa on June 13, 2015, 07:46:39 pm
@renabor

Quote
...Is it possible to automate the generation of a unique Id for the newly created object?

The unique ID is generated when you do a component "anchorage" ...

Quote
...the correct way to work with jHttpClient authentication ...

It is a server design/implementation question ... some server wait for :

SetAuthenticationHost('', -1);  //--> AuthScope(null, -1)   

Quote
...Can you extend the jHttpClient Class implementing the UPDATE and DELETE methods?

Ok. I will try .....

Quote
...I have many Forms in my app and I need different menu in each form, how can I achieve this result?

Ok. I am doing now ..... [adding support to ....]

Quote
...I use intensely jSqlLite and jHttpClient in any form of my app but I'm unable to share the first instance so I recreate it in every new form.  Is there a way to improve it?

You can try:  add "uses" [your first instance] after the "implementaion" section ...

Quote
...Can you suggest me a method to access Contacts for reading and writing them?

for reading [and pick]: it is supported in jIntentManager

for writing: Ok. I will do a jContactManager component ...

.....................

@m4u_hoahoctro

Please, put just "unit1.pas" and "unit1.lfm" .... [not a too big file !!!!]
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 14, 2015, 01:55:21 am


Quote

@m4u_hoahoctro

Please, put just "unit1.pas" and "unit1.lfm" .... [not a too big file !!!!]

ok. this is link download of above files:

https://drive.google.com/file/d/0Bx3SDL5wwBBYYVNYQ0R3VjVoUm8/view?usp=sharing (https://drive.google.com/file/d/0Bx3SDL5wwBBYYVNYQ0R3VjVoUm8/view?usp=sharing)
Title: Re: Android Module Wizard
Post by: renabor on June 14, 2015, 10:02:51 am
@jmpessoa

Finally I got authentication working!

Changing Controls.java:

Code: [Select]
in class AsyncHttpClientPostNameValueData

after
                    HttpPost httppost = new HttpPost(_stringUrl);
adding this code:
                    if (mAuthenticationMode != 0) {
                            String _credentials = mUSERNAME + ":" + mPASSWORD;
                            String _base64EncodedCredentials = Base64.encodeToString(_credentials.getBytes(), Base64.NO_WRAP);
                            httppost.addHeader("Authorization", "Basic " + _base64EncodedCredentials);
                    }

Code: [Select]
in class AsyncHttpClientGet
after:
                    HttpGet httpget = new HttpGet(stringUrl[0]);
adding this code:
                    if (mAuthenticationMode != 0) {
                            String _credentials = mUSERNAME + ":" + mPASSWORD;
                            String _base64EncodedCredentials = Base64.encodeToString(_credentials.getBytes(), Base64.NO_WRAP);
                            httpget.addHeader("Authorization", "Basic " + _base64EncodedCredentials);
                    }
Title: Re: Android Module Wizard
Post by: jmpessoa on June 15, 2015, 12:38:01 am
Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 30 - 14 June 2015 -

   IMPROVEMENTS!   

      jMenu component:         
         New! Added support to different menu in each form! // <<--- @renabor's request and suggestion!
         New! Methods, Propery and Events
      jForm
         News! Events/Properties to handler the news from jMenu

   UPDATED: Demo AppMenuDemo

   FIXs   
      jForm      :fixed form close callback
      jHttpClient   :fixed "basic authentication" //<--- Thanks to @renabor !!!   

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Thanks to All and special thanks to @renabor !!
Title: Re: Android Module Wizard
Post by: Công Tuấn on June 16, 2015, 04:48:29 am
@jmpessoa
How to open sdcard on android emulator?, i want to create folder and add image or video from computer to it :D
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 16, 2015, 11:08:57 am
@jmpessoa
How to open sdcard on android emulator?, i want to create folder and add image or video from computer to it :D

Đối với genymotion ( With genymotion emulator )http://stackoverflow.com/questions/18530114/accessing-files-from-genymotion-sd-card (http://stackoverflow.com/questions/18530114/accessing-files-from-genymotion-sd-card)

Những máy ảo còn lại, bạn có thể sử dụng đường dẫn /sdcard/.... trong câu lệnh xử lý file khi cần )
( You can also use patch /sdcard/.... in progress command file in your application )
Dù vậy, các thử nghiệm sd card chỉ nên thực hiện trên thiết bị thực sẽ mang lại kết quả tốt hơn ( However, you should have a android phone to have a better result

Title: Re: Android Module Wizard
Post by: Leledumbo on June 16, 2015, 12:42:31 pm
In the latest commit, a hello world app seems to be caught in an infinite loop in both 4.2.2 emulator & 4.4.2 real device. I'm using a very fresh copy of FPC & Lazarus trunk, targetting ARMv7A + VFPv3. ADB says: "Skipping XX frames! The application may be doing too much work on its main thread."
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 16, 2015, 05:29:39 pm
In the latest commit, a hello world app seems to be caught in an infinite loop in both 4.2.2 emulator & 4.4.2 real device. I'm using a very fresh copy of FPC & Lazarus trunk, targetting ARMv7A + VFPv3. ADB says: "Skipping XX frames! The application may be doing too much work on its main thread."

Put your code here, I also want to see  the error you met
or you are meaning to helloword demo ?
Title: Re: Android Module Wizard
Post by: Leledumbo on June 17, 2015, 12:20:39 am
In the latest commit, a hello world app seems to be caught in an infinite loop in both 4.2.2 emulator & 4.4.2 real device. I'm using a very fresh copy of FPC & Lazarus trunk, targetting ARMv7A + VFPv3. ADB says: "Skipping XX frames! The application may be doing too much work on its main thread."

Put your code here, I also want to see  the error you met
or you are meaning to helloword demo ?
Yes, that demo. I guess I build my FPC wrong because I recently played with raspberrypi which uses hard float. I'll try to rebuild.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 17, 2015, 01:46:07 am
Well, I do a test just  NOW.... it seems continues running right ...

My systems:

Laz4Android
         Last update:2015-02-25
         FPC: 3.1.1 trunk svn 29987 win32/arm-android/i386-android/jvm-android
         Lazarus:1.5 trunk svn 47987
         Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)
         http://sourceforge.net/projects/laz4android/files/?source=navbar
         :To Install [*.7z], please, read the "Laz4Android_readme.txt"

and old:

Laz4Android [Laz 1.3 + FPC 2.7.1]

Devices: Android 4.3 and 4.4.2
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on June 17, 2015, 09:33:46 am
@jmpessoa

about my problem, have you found reason yet ? why it couldn't play video file ? I downloaded it from youtube  :(

ps: link of files unit1.lr and unit1.pas have been updated above
Title: Re: Android Module Wizard
Post by: Leledumbo on June 17, 2015, 03:33:18 pm
Well, I do a test just  NOW.... it seems continues running right ...
My fault, indeed. I don't use any -Cp option anymore when building the compiler and rtl, only -Cf, and it works again.
Title: Re: Android Module Wizard
Post by: renabor on June 19, 2015, 09:04:30 am
Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 30 - 14 June 2015 -

   IMPROVEMENTS!   

      jMenu component:         
         New! Added support to different menu in each form! // <<--- @renabor's request and suggestion!
         New! Methods, Propery and Events
      jForm
         News! Events/Properties to handler the news from jMenu

   UPDATED: Demo AppMenuDemo

   FIXs   
      jForm      :fixed form close callback
      jHttpClient   :fixed "basic authentication" //<--- Thanks to @renabor !!!   

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Thanks to All and special thanks to @renabor !!

Thank you very much @jmpessoa, for code and cite!

I think something where wrong in the last revision that give me many problems and errors. I use rev. 29 once again.
The main problem reside in impossibility to upgrade Code Templates (Lazarus is unable to find Project file), and    throughout compiling report many Access Violation errors.

And now some suggestions, requests and bugs:

Best regards and thanks for all
Title: Re: Android Module Wizard
Post by: Leledumbo on June 19, 2015, 09:58:55 am
@jmpessoa, I get the attached image (that "read error" dialog) everytime I close lazarus with lazandroidmodulewizard project opened. It's not a problem (I'm closing the IDE after all), but it's annoying.

This is what the log says:
Code: [Select]
NOTE: Window with stalled focus found!, faking focus-out event
[TJITComponentList.DestroyJITComponent] ERROR destroying component Error: Access violation
  Stack trace:
  $0000000001307E5D line 4539 of androidwidget.pas
  $00000000012FDEB8 line 2154 of androidwidget.pas
  $0000000000432022
  $0000000000A722FF line 753 of ../designer/jitforms.pp
  $0000000000A9DB7F line 584 of customformeditor.pp
  $0000000000A8974C line 668 of ../designer/designer.pp
  $0000000000D6C757 line 6719 of sourcefilemanager.pas
  $0000000000D54A19 line 2273 of sourcefilemanager.pas
  $0000000000D5CA3D line 3748 of sourcefilemanager.pas
  $00000000004BFCA8 line 6183 of main.pp
  $00000000004A5FEB line 1993 of main.pp
  $0000000000477B19 line 2171 of include/customform.inc
  $0000000000477851 line 2081 of include/customform.inc
  $0000000000477C8D line 2179 of include/customform.inc
  $0000000000432549
  $00000000006BC130 line 5342 of include/wincontrol.inc
  $0000000000474D33 line 1444 of include/customform.inc
TCustomFormEditor.JITListException List.CurReadStreamClass=nil nil
Title: Re: Android Module Wizard
Post by: jmpessoa on June 19, 2015, 06:08:54 pm

Yes,  you're right!  I also noticed that here in my system [Win] ... I'll try find fix this error...

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on June 19, 2015, 07:48:42 pm
One more thing, Lazarus freezes when I use Run->[Lamw] Build apk and run. It freezes when running adb with no emulator/real device running, my guess is that the external tool is not executed asynchronously. Tools that I add to Configure External Tools seem to execute asynchronously, though. Very weird.
Title: Re: Android Module Wizard
Post by: A.S. on June 19, 2015, 09:05:53 pm
Leledumbo, Run->[Lamw] Build apk and run uses external tools for building/installing/running purposes. But it also determines connected devices, and this check is not asynchronous.
Title: Re: Android Module Wizard
Post by: A.S. on June 19, 2015, 09:20:32 pm

Yes,  you're right!  I also noticed that here in my system [Win] ... I'll try find fix this error...

Thank you!

Please check. It seems, I fixed it.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 19, 2015, 11:03:36 pm

@ A.S.

Quote
Please check. It seems, I fixed it.

Yes, now it's  ok!

Thank You!
Title: Re: Android Module Wizard
Post by: renabor on June 21, 2015, 10:32:17 am
......

And now some suggestions, requests and bugs:
  • Add the OnBack Event In jCustomDialog
  • The function JNIPrompt is not fired when a form is reactivated trough a Back in a second form, solution could be to add an OnComingBack event to jForm, or firing JNIPrompt event on coming back. At this time data displayed cannot be refreshed in automatic on coming back to first form
  • The jContextMenu cannot open a form
  • When a jContextMenu is linked to a jListView would very helpful that the Caption of the Item clicked where accessible or passed. My need is to edit or delete the record associated with the item clicked
  • jListView is lacking in configurability in order to display many columns of data. What do you think about adding Columns or  something like Tab to jListView?
  • Add an onClick event to jEditText, to make it possible, i.e., to open in automatic a jDatePickerDialog
  • Add an itxCurrency mask for jEditText that admits dot and comma with numbers together, or add dot and comma to itxNumber

Last request is partially resolved modifying in Controls.java (line 1436) :
Code: [Select]
        if(str.equals("NUMBER")) {
            this.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
        }
with
        if(str.equals("NUMBER")) {
            this.setInputType(InputType.TYPE_CLASS_NUMBER| InputType.TYPE_NUMBER_FLAG_DECIMAL|
                     InputType.TYPE_NUMBER_FLAG_SIGNED);
       }

that permits input of numbers [0..9], a minus sign prepended and a singular punctuation sign (only point, not comma)

Best regards
Title: Re: Android Module Wizard
Post by: renabor on June 23, 2015, 12:17:08 pm
@jmpessoa
For my purpose I need the Id of last inserted row, but my effort are unsuccessful.

I tried to add this method in Controls.java, related to class jSqliteCursor:
Code: [Select]
public long GetLastId() {
                if (this.cursor != null) {
                        int index = 0;
                        index = this.cursor.getColumnIndex("ROWID");
                        this.MoveToLast();
                        return this.GetValueAsLong(index);
        }
        else{
                return -1;
        }
}

this in Laz_and_controls:
Code: [Select]
function jSqliteCursor.GetLastId: integer;
begin
   if not FInitialized  then Exit;
   Result:= integer(jSqliteCursor_GetLastId(FjEnv, FjObject ));
end;     

and this in And_jni_Bridge:
Code: [Select]
Function jSqliteCursor_GetLastId(env:PJNIEnv;  SqliteCursor: jObject): integer;
var
 _jMethod : jMethodID = nil;
 cls: jClass;
begin
 cls := env^.GetObjectClass(env, SqliteCursor);
  _jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');
 Result := integer(env^.CallLongMethod(env,SqliteCursor,_jMethod));
 env^.DeleteLocalRef(env, cls);
end;

and the log report:

I/dalvikvm( 4112): java.lang.NoSuchMethodError: no method with name='GetLastId' signature='()I' in class Lcom/suevoz/borsa/jSqliteCursor;

so, where is the error? Can you help me?

thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on June 23, 2015, 05:49:45 pm
@renabor

OK, java/JNI 'long' signature is "J", then

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');

change to:

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()J');

Title: Re: Android Module Wizard
Post by: renabor on June 23, 2015, 06:38:37 pm
@renabor

OK, java/JNI 'long' signature is "J", then

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');

change to:

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()J');

Now the error is:

JNI WARNING: expected return type 'I'

 %)

Title: Re: Android Module Wizard
Post by: jmpessoa on June 23, 2015, 06:46:42 pm


Ok,  change all your pascal function result "integer" to int64 ....
Title: Re: Android Module Wizard
Post by: jmpessoa on June 30, 2015, 09:57:25 pm
Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 31 - 30 June 2015 -

   NEW! jContactManager component [Partial support] // <<--- @renabor's request and suggestion!
      
      warning [need]:
      <uses-permission android:name="android.permission.READ_CONTACTS"/>
      <uses-permission android:name="android.permission.WRITE_CONTACTS"/>

   NEW! AppContactManagerDemo1
   NEW! AppContactManagerDemo2

   IMPROVEMENTS!   

          jCustomDialog component:         
         New! OnBackKeyPressed property event// <<--- @renabor's request and suggestion!

         UPDATED: Demo AppCustomDialogDemo1

          jEditText component:         
         New! OnClick property event // <<--- @renabor's request and suggestion!
         New! itxCurrency mask // <<--- @renabor's request and suggestion!

         UPDATED: AppEditTextDemo1
         
      jForm
         New! OnJNIPrompt event now fires when a form is reactivated trough a Backkeypressed!
         // <<--- @renabor's request and suggestion!    

         Fixed! jForms stack behaviour

         UPDATED: Demo AppTest1

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!


Thanks to All and special thanks to @renabor !!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 03, 2015, 05:15:20 pm
@jmpessoa

How to create an applicaiton that can connect to a database on free hosting, read datas in database and save from tstringlist ? (theory all them is text only). Seems your demos doesn't mention about this.
thanks
Title: Re: Android Module Wizard
Post by: renabor on July 03, 2015, 06:46:25 pm
@jmpessoa

Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 31 - 30 June 2015 -

   NEW! jContactManager component [Partial support] // <<--- @renabor's request and suggestion!
      
      warning [need]:
      <uses-permission android:name="android.permission.READ_CONTACTS"/>
      <uses-permission android:name="android.permission.WRITE_CONTACTS"/>

   NEW! AppContactManagerDemo1
   NEW! AppContactManagerDemo2

   IMPROVEMENTS!   

          jCustomDialog component:         
         New! OnBackKeyPressed property event// <<--- @renabor's request and suggestion!

         UPDATED: Demo AppCustomDialogDemo1

          jEditText component:         
         New! OnClick property event // <<--- @renabor's request and suggestion!
         New! itxCurrency mask // <<--- @renabor's request and suggestion!

         UPDATED: AppEditTextDemo1
         
      jForm
         New! OnJNIPrompt event now fires when a form is reactivated trough a Backkeypressed!
         // <<--- @renabor's request and suggestion!    

         Fixed! jForms stack behaviour

         UPDATED: Demo AppTest1

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!


Thanks to All and special thanks to @renabor !!

Thank you very much for all!

I've tried improvements and are all precious!
jContactManager is a must, although I have not tried it so much, I'm working on another project now.

the OnBackKeyPressed in CustomDialog property is great, but break the propagation of Event for soft backkey and del key, here an amended version that handle both soft and hard backkey press:
Code: [Select]
line ~ 10069 in Controls.java

mDialog.setOnKeyListener(new Dialog.OnKeyListener() {
@Override
  public  boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
     if (event.getAction() == KeyEvent.ACTION_UP) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
             controls.pOnCustomDialogBackKeyPressed(pascalObj, mTitle);
             if (mDialog != null) mDialog.dismiss();
             return false;
        } else if (keyCode == KeyEvent.KEYCODE_ENTER) {
            InputMethodManager imm = (InputMethodManager) controls.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getWindowToken(), 0);
            controls.pOnEnter(pascalObj);
            return true;
        }
     }
     return false;
   }
});

Finally I've found a solution for my problem in obtaining the item index clicked out of jListView, here the code that add a listener to OnItemLongClick Event and add the property ItemIndex to jListView:
Code: [Select]
----- in  Laz_And_Controls.pas
line 1040
    function GetItemIndex: integer;
line 1083
    property ItemIndex: integer read GetItemIndex;
line 5120
    function jListView.GetItemIndex: integer;
    begin
      Result:= Self.Items.Count;
      if FInitialized then
        Result:= jListView_GetItemIndex(FjEnv, FjObject );
    end;

----- in  And_jni_Bridge.pas
line 485
  function jListView_GetItemIndex(env:PJNIEnv; ListView : jObject): integer;
line 3915
  function jListView_GetItemIndex(env:PJNIEnv;  ListView : jObject): integer;
  var
    _jMethod : jMethodID = nil;
    cls: jClass;
  begin
    cls := env^.GetObjectClass(env, ListView);
    _jMethod:= env^.GetMethodID(env, cls, 'GetItemIndex', '()I');
    Result:= env^.CallIntMethod(env,ListView,_jMethod);
    env^.DeleteLocalRef(env, cls);
  end;

------- in Controls.java
line 2785
  int itemIndex = -1;
line ~ 2887 
  itemIndex = position;
line ~ 2892
  onItemLongClickListener = new OnItemLongClickListener() {
    public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
      itemIndex = position;
      return false;
    }
  };
setOnItemLongClickListener(onItemLongClickListener);
line 2949
  public int GetItemIndex() {
    return itemIndex;
  }

Now I'm in trouble with jListView adapter, I'm trying to adapt this example

http://www.codelearn.org/android-tutorial/android-listview

any idea is really appreciated
Title: Re: Android Module Wizard
Post by: jmpessoa on July 04, 2015, 12:12:58 am
@renabor,

Quote
....I'm trying to adapt this example http://www.codelearn.org/android-tutorial/android-listview

The  jListView already support this possibility!

try this properties: widgetItem, widgetText, imageItem, ItemLayout,
 textDecoreted and textSizeDecoreted ...

Thank You!
Title: Re: Android Module Wizard
Post by: jmpessoa on July 06, 2015, 07:49:29 pm
Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 32 - 05 July 2015 -

   IMPROVEMENTS!   

          jListView component:         
         New! event/properties:   
            OnDrawItemBitmap
            OnDrawItemTextColor
            OnLongClick <<--- @renabor's request and suggestion!

         warning/changed: "OnClickItemCaption" was lost [sorry ...], please, copy your code to "new" OnClickItem

          jGridView component:         
         New! Event/properties:   
            OnDrawItemBitmap
            OnDrawItemTextColor      
            OnLongClick

          jDigitalClock component:         
         New! properties:
            FontColor
            FontSize
      jSqliteCursor
         New! method:
            GetValueAsString(rowPosition, columnName) <<--- @renabor's suggestion [GetLastID]!
                     rowPosition = -1 --> move to last!
      
      jHttpClient
         New! synchronous methods:  // <<---- by Fatih KILIÇ
            Get(url): string            

            AddNameValueData(name,value)
            Post(url) 

         warning/changed: asynchronous "Get" methods was renamed to "GetAsync"
         warning/changed: asynchronous "PostNameValueData" methods was renamed to "PostNameValueDataAsync"

         New!
            AddNameValueData(name,value)
            PostNameValueDataAsync(url) 
         
      jShellcommand
         warning/changed: asynchronous "Execute" method was renamed to "ExecuteAsync"

      jContactManager
         warning/changed: asynchronous "GetContact" method was renamed to "GetContactAsync"

   UPDATED: ALL Demos !!!

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Thanks to All!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 07, 2015, 01:37:12 pm
Hello Jmpessoa
 

There are two issues for new version.

1.What to use instead «gapp.BaseIndex»?
2. How to disable OnJNIPrompt event,   when a form is reactivated trough a Backkeypressed?

With Respect

rx3.fireproof


With the new changes, nothing works. I'm back on 06.28
Title: Re: Android Module Wizard
Post by: jmpessoa on July 08, 2015, 07:03:11 pm
@rx3.fireproof

Please, wait .... I will try a solution  [today!] !

Thank you!

Edited:

Quote
2. How to disable OnJNIPrompt event,   when a form is reactivated trough a Backkeypressed?

solution: Added jForm property [boolean] PromptOnBackKey ... just do:

 .PromptOnBackKey := False;

Edited:

Quote
1.What to use instead «gapp.BaseIndex»?

solution: Added jForm property [boolean] TryBacktrackOnClose ... just do:

 .TryBacktrackOnClose:= True   for all forms in the stack ...

example:

1. AndroidModule1 ["actMain"]  open form2:

Code: [Select]
  if(AndroidModule2 = nil) then
  begin
    gApp.CreateForm(TAndroidModule2, AndroidModule2);
    AndroidModule2.PromptOnBackKey:= False;
    AndroidModule2.TryBacktrackOnClose:= True;
    AndroidModule2.Init(gApp);
  end
  else
  begin
    AndroidModule2.Show;
  end;

2. AndroidModule2 ["actRecyclable"]  open form3:

Code: [Select]
  if(AndroidModule3 = nil) then
  begin
    gApp.CreateForm(TAndroidModule3, AndroidModule3);
    AndroidModule3.PromptOnBackKey:= False;
    AndroidModule3.TryBacktrackOnClose:= True;
    AndroidModule3.Init(gApp);
  end
  else
  begin
    AndroidModule3.Show;
  end;

3. AndroidModule3 ["actRecyclable"]  open form4:

Code: [Select]
  if(AndroidModule3 = nil) then
  begin
    gApp.CreateForm(TAndroidModule4, AndroidModule4);
    AndroidModule4.PromptOnBackKey:= False;
    AndroidModule4.TryBacktrackOnClose:= True;
    AndroidModule4.Init(gApp);
  end
  else
  begin
    AndroidModule4.Show;
  end;

Now if  you close form4 then all [3 and 2]   forms [actRecyclable]  will close too!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 09, 2015, 04:17:45 am
@jmpessoa

Can jimageview and jmediaplayer show/play an image/a song from link on internet ?   :o
Title: Re: Android Module Wizard
Post by: jmpessoa on July 09, 2015, 04:34:26 am
Hello m4u_hoahoctro !

Yes! some links to test ? 
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 09, 2015, 12:03:19 pm
Hello m4u_hoahoctro !

Yes! some links to test ?

http://i.imgur.com/n2lQnkI.png

I could get content from web, but haven't known how to do with image and media file yet
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 09, 2015, 05:09:53 pm
Hello Jmpessoa

Disable OnJNIPrompt event works. Thank you.

On the first question about the «gapp.BaseIndex».

I have a more complex application logic.

As an example of.

From the form 1 you can create the form 2 or the form 3.
From  the form 2 or the form 3 you can create the form 4.
From the form 4 you can create the form 5.
The Form 5 can be created from the Form 1.

I made a working example on version 06.28 by reference https://yadi.sk/d/YyEGt-gUhmWuQ

How to make this example on 06.32 version without «gapp.BaseIndex» I don't understand.

In a real application I have a 27 forms. The data transmitted between them by global records with many fields (string,  boolean and double).


With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on July 09, 2015, 08:30:43 pm
Hello rx3.fireproof!

Try:

//gapp.BaseIndex

What happens if you comment this line? 

The form now know your [own] base... so, if you close it, you will return to the form where it was created [or "showed" :edited after bug fixed !]! 

But you can try return to "main" form using the new property "TryBacktrackOnClose:= True"
in all chain ...the process will stop [before main] if some form [in the way] was not set "TryBacktrackOnClose:= True"


The ideia is not have code like this [try comment this lines too!]:

Code: [Select]
form_index_0_level:=-1;
  form_index_1_level:=-1;
  form_index_2_level:=-1;
  form_index:=-1;

the logic must be "controled" by framework!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 09, 2015, 09:14:42 pm
@ Jmpessoa

If the chain one - control by framework .

What if three chains.
Form5 already exists.

In each chain there is potentially private data.

To destroy the form5 is impossible. I have not found a way to destroy the form5 (form2, form3, form4...) and free the memory. So I use the index for forms.

Please show how to use  "control by framework"  in the "Sample" (three chains).  I will study and implement in my project.

Now sample is stable and has no bugs (only takes memory - sorry) .  I'm not a programmer, what's inside the user is not interested.


With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on July 09, 2015, 09:40:32 pm
Ok.  I am just doing you example:

Quote
From the form 1 you can create the form 2 or the form 3.
From  the form 2 or the form 3 you can create the form 4.
From the form 4 you can create the form 5.
The Form 5 can be created from the Form 1.

 ... some minutes ...

Ok I found a bug! Please fix here:    [<< ----   rx3!]

"androidwidget.pas"

Code: [Select]
Procedure jForm.Show;
begin
  if not FInitialized then Exit;
  if FVisible then Exit;
  FormState := fsFormWork;
  FVisible:= True;

  FormBaseIndex:= gApp.TopIndex; // << ----   rx3!

  gApp.TopIndex:= Self.FormIndex;
  jForm_Show2(FjEnv,FjObject,FAnimation.In_);
  if Assigned(FOnJNIPrompt) then FOnJNIPrompt(Self);    //*****
end;

Now it is OK to all chains!

my code:

form1 [Main]

Code: [Select]
unit unit1;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
    jButton1: jButton;
    jButton2: jButton;
    jButton3: jButton;
    jTextView1: jTextView;
    jTextView2: jTextView;
    procedure jButton1Click(Sender: TObject);
    procedure jButton2Click(Sender: TObject);
    procedure jButton3Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule1: TAndroidModule1;

implementation

uses Unit2, Unit3, Unit5;

{$R *.lfm}

{ TAndroidModule1 }


procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
    if AndroidModule2 = nil then begin
     gApp.CreateForm(TAndroidModule2, AndroidModule2);
     AndroidModule2.Init(gApp);
   end
   else
   begin
     AndroidModule2.Show;
   end;
end;

procedure TAndroidModule1.jButton2Click(Sender: TObject);
begin
  if AndroidModule3 = nil then begin
     gApp.CreateForm(TAndroidModule3, AndroidModule3);
     AndroidModule3.Init(gApp);
  end
  else
  begin
     AndroidModule3.Show;
  end;
end;

procedure TAndroidModule1.jButton3Click(Sender: TObject);
begin
   if AndroidModule5 = nil then begin
     gApp.CreateForm(TAndroidModule5, AndroidModule5);
     AndroidModule5.Init(gApp);
   end
   else
   begin
     AndroidModule5.Show;
   end;
end;

end.

form2  [Recyclable]

Code: [Select]
unit unit2;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule2 }

  TAndroidModule2 = class(jForm)
    jButton1: jButton;
    jTextView1: jTextView;
    procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule2: TAndroidModule2;

implementation

uses Unit4;


{$R *.lfm}

{ TAndroidModule2 }

procedure TAndroidModule2.jButton1Click(Sender: TObject);
begin
   if AndroidModule4 = nil then begin
     gApp.CreateForm(TAndroidModule4, AndroidModule4);
     AndroidModule4.Init(gApp);
   end
   else
   begin
     AndroidModule4.Show;
   end;
end;

end.

form3  [Recyclable]

Code: [Select]
unit unit3;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule3 }

  TAndroidModule3 = class(jForm)
    jButton1: jButton;
    jTextView1: jTextView;
    procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule3: TAndroidModule3;

implementation

uses Unit4;

{$R *.lfm}

{ TAndroidModule3 }

procedure TAndroidModule3.jButton1Click(Sender: TObject);
begin
   if AndroidModule4 = nil then begin
     gApp.CreateForm(TAndroidModule4, AndroidModule4);
     AndroidModule4.Init(gApp);
   end
   else
   begin
     AndroidModule4.Show;
   end;
end;

end.

form4  [Recyclable]

Code: [Select]
unit unit4;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule4 }

  TAndroidModule4 = class(jForm)
    jButton1: jButton;
    jTextView1: jTextView;
    procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule4: TAndroidModule4;

implementation

uses Unit5;

{$R *.lfm}

{ TAndroidModule4 }

procedure TAndroidModule4.jButton1Click(Sender: TObject);
begin
   if AndroidModule5 = nil then begin
     gApp.CreateForm(TAndroidModule5, AndroidModule5);
     AndroidModule5.Init(gApp);
   end
   else
   begin
     AndroidModule5.Show;
   end;
end;

end.

form5  [Recyclable]

Code: [Select]
unit unit5;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule5 }

  TAndroidModule5 = class(jForm)
    jButton1: jButton;
    jTextView1: jTextView;
    procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule5: TAndroidModule5;

implementation

{$R *.lfm}

{ TAndroidModule5 }

procedure TAndroidModule5.jButton1Click(Sender: TObject);
begin
  showMessage('Hello Form 5');
end;

end.

Thank You!!!

PS. Late I will do a new revision release: New jSeekBar and the bug fixed!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 10, 2015, 03:25:00 am
Please give me an example, jmpessoa
thanks :)
Title: Re: Android Module Wizard
Post by: jmpessoa on July 10, 2015, 04:14:52 am
@m4u_hoahoctro,

Ok. ...some minutes..

Edited:

You can create a new project and replace yours  "Unit1.pas" and "Unit1.lfm"  with my:


code:  "Unit1.pas"
Code: [Select]
unit unit1;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  Laz_And_Controls_Events, AndroidWidget, imagefilemanager, mediaplayer,
  surfaceview;

type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
    jAsyncTask1: jAsyncTask;
    jButton1: jButton;
    jButton2: jButton;
    jButton3: jButton;
    jDialogProgress1: jDialogProgress;
    jImageFileManager1: jImageFileManager;
    jImageView1: jImageView;
    jMediaPlayer1: jMediaPlayer;
    jSurfaceView1: jSurfaceView;
    jTextView1: jTextView;
    procedure AndroidModule1JNIPrompt(Sender: TObject);
    procedure jAsyncTask1DoInBackground(Sender: TObject; progress: integer; out
      keepInBackground: boolean);
    procedure jAsyncTask1PostExecute(Sender: TObject; progress: integer);
    procedure jButton1Click(Sender: TObject);
    procedure jButton2Click(Sender: TObject);
    procedure jButton3Click(Sender: TObject);
    procedure jMediaPlayer1Completion(Sender: TObject);
    procedure jMediaPlayer1Prepared(Sender: TObject; videoWidth: integer;
      videoHeight: integer);
    procedure jSurfaceView1SurfaceCreated(Sender: TObject;
      surfaceHolder: jObject);
  private
    {private declarations}
    FActionType: integer;
  public
    {public declarations}

  end;

var
  AndroidModule1: TAndroidModule1;
  FImageBitmap: jObject;

implementation

{$R *.lfm}

{ TAndroidModule1 }

//try Wifi ...
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
  if not Self.IsWifiEnabled() then Self.SetWifiEnabled(True);
end;

procedure TAndroidModule1.jAsyncTask1DoInBackground(Sender: TObject;
  progress: integer; out keepInBackground: boolean);
begin
   case FActionType of
     1: begin //sound
             jMediaPlayer1.SetDataSource('http://www.hrupin.com/wp-content/uploads/mp3/testsong_20_sec.mp3');
             jMediaPlayer1.Prepare();  ////Dispatch --> OnPrepared !
        end;

     2: begin //image
              FImageBitmap:= jImageFileManager1.LoadFromURL('http://miftyisbored.com/wp-content/uploads/2013/07/nature-sound-spa-app.png'); //'http://i.imgur.com/n2lQnkI.png
              FImageBitmap:= Get_jObjGlobalRef(FImageBitmap);
        end;

      3: begin  //video
           jMediaPlayer1.SetDataSource('http://bffmedia.com/bigbunny.mp4');
           jMediaPlayer1.Prepare();  ////Dispatch --> OnPrepared !
         end;
   end;
   keepInBackground:= False;
end;

procedure TAndroidModule1.jAsyncTask1PostExecute(Sender: TObject;
  progress: integer);
begin
  jAsyncTask1.Done;
  jDialogProgress1.Stop;
  if FImageBitmap <> nil then
  begin
     jImageView1.SetImageBitmap(FImageBitmap);
     Delete_jGlobalRef(FImageBitmap);
     FImageBitmap:= nil;
  end;
end;

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
  FActionType:= 1;
  if not jAsyncTask1.Running then
  begin
    jDialogProgress1.Start;
    jAsyncTask1.Execute;    //Dispatch --> DoInBackground!
  end
end;

procedure TAndroidModule1.jButton2Click(Sender: TObject);
begin
  FActionType:= 2;
  if not jAsyncTask1.Running then
  begin
    jDialogProgress1.Start;
    jAsyncTask1.Execute;    //Dispatch --> DoInBackground
  end
end;

procedure TAndroidModule1.jButton3Click(Sender: TObject);
begin
  FActionType:= 3;
  if not jAsyncTask1.Running then
  begin
    jDialogProgress1.Start;
    jAsyncTask1.Execute;   //Dispatch --> DoInBackground
  end
end;

//here Start/Play  the Sound/Video
procedure TAndroidModule1.jMediaPlayer1Prepared(Sender: TObject;
  videoWidth: integer; videoHeight: integer);
begin
  jMediaPlayer1.Start();
end;

//needed to Show Video
procedure TAndroidModule1.jSurfaceView1SurfaceCreated(Sender: TObject;
  surfaceHolder: jObject);
begin
   jMediaPlayer1.SetDisplay(surfaceHolder);
end;

//Sound/Video End ...!
procedure TAndroidModule1.jMediaPlayer1Completion(Sender: TObject);
begin
   ShowMessage('The End!');
end;

end.


code:  "Unit1.lfm"
Code: [Select]
object AndroidModule1: TAndroidModule1
  Left = 285
  Top = 163
  Width = 320
  Height = 400
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule1'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  OnJNIPrompt = AndroidModule1JNIPrompt
  object jTextView1: jTextView
    Left = 31
    Top = 5
    Width = 258
    Height = 20
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'App Load Image Video Sound From Internet'
    Alignment = taLeft
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    TextTypeFace = tfNormal
    Id = 7138094
  end
  object jButton1: jButton
    Left = 2
    Top = 34
    Width = 92
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneThirdOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Sound'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    Id = 5324807
  end
  object jButton2: jButton
    Left = 114
    Top = 34
    Width = 92
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpOneThirdOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Image'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton2Click
    Id = 8462655
  end
  object jButton3: jButton
    Left = 226
    Top = 34
    Width = 92
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneThirdOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Video'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton3Click
    Id = 1641892
  end
  object jImageView1: jImageView
    Left = 8
    Top = 272
    Width = 304
    Height = 128
    Visible = True
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpBottom]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    ImageIndex = -1
    BackgroundColor = colbrDefault
    ImageScaleType = scaleCenter
    Id = 1481240
  end
  object jSurfaceView1: jSurfaceView
    Left = 6
    Top = 80
    Width = 306
    Height = 96
    MarginLeft = 10
    MarginTop = 10
    MarginRight = 10
    MarginBottom = 10
    Visible = True
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpOneThirdOfParent
    BackgroundColor = colbrDefault
    PaintColor = colbrRed
    OnSurfaceCreated = jSurfaceView1SurfaceCreated
    Id = 3868251
  end
  object jAsyncTask1: jAsyncTask
    OnDoInBackground = jAsyncTask1DoInBackground
    OnPostExecute = jAsyncTask1PostExecute
    left = 248
    top = 224
  end
  object jImageFileManager1: jImageFileManager
    left = 136
    top = 184
  end
  object jDialogProgress1: jDialogProgress
    Title = 'Lamw: Lazarus Android Module Wizard'
    Msg = 'Please, wait...'
    left = 248
    top = 168
  end
  object jMediaPlayer1: jMediaPlayer
    OnPrepared = jMediaPlayer1Prepared
    OnCompletion = jMediaPlayer1Completion
    left = 40
    top = 168
  end
end

Thank you!
Title: Re: Android Module Wizard
Post by: Leledumbo on July 10, 2015, 09:29:37 am
A little question regarding jHTTPClient: is it stateful or stateless? I mean, can I use it to simulate a browsing session? I want to create some kind of web crawler, so I need to go to certain page, do login, save cookie, then browse the login-protected pages. Save cookie is be the key, if it can, then I think it's possible to do what I want.
Title: Re: Android Module Wizard
Post by: jmpessoa on July 10, 2015, 03:39:59 pm
@Leledumbo,

At the moment  jHTTPClient is stateless ... supporting Get and Post [name=value] data
and basic authentication....

OK, I will try implement cookies!

Thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on July 10, 2015, 04:19:28 pm
Hi All!

There is an updated revision of the "Lamw" 

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 33 - 09 July 2015 -

   NEW! jSeekBar component

   IMPROVEMENTS!   
         
      jForm
         New!
            properties: // <<--- @rx3.fireproof's request and suggestion!
               PromptOnBackKey [default=True]

               TryBacktrackOnClose [default=False]

                  The form now know your [own] base... so,
                  if you close it, you will return to the form where it was created
                  [or "showed"!].  But you can try return to "main form" form using the new
                  property "TryBacktrackOnClose:= True" in all [forms] chains ...
                  [warning]the process will stop [before main from] if some form [in the way]
                  was not set "TryBacktrackOnClose:= True"

   NEW! AppSeekBarDemo1   [multiples forms demos, too]
         
   UPDATED: Demo AppTest1  [multiples forms demos]

   NEW!  Demo: AppLoadImageVideoSoundFromInternet <<--- @m4u_hoahoctro's request and suggestion!

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Thanks to All!

Special thanks to @rx3.fireproof and @m4u_hoahoctro
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 11, 2015, 12:00:03 am
@ Jmpessoa

Everything works. Thank you.

There is a small question for the continuation of this theme on the chains.

How to use code to determine  what the form will active when  press the back button? Is this possible?

With Respect

rx3.fireproof

Title: Re: Android Module Wizard
Post by: jmpessoa on July 11, 2015, 12:41:08 am
Yes!

Code: [Select]
procedure TAndroidModule5.jButton1Click(Sender: TObject);
var
   baseform: jForm;
begin
  baseform:= jForm(gApp.Forms.Stack[Self.FormBaseIndex].Form);
  ShowMessage(baseform.Name);
  ShowMessage(IntToStr(baseform.Tag));
end;   
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 11, 2015, 12:56:37 pm
Hi jmpessoa, thanks very for your example  :)

But I haven't even seen this code before

Code: [Select]
FImageBitmap:= Get_jObjGlobalRef(FImageBitmap);       
and
Code: [Select]
Delete_jGlobalRef(FImageBitmap);   
Which reference page I can find more "strange commands" same as above  ;)

With application run on PC, we can get position of mouse cursor, so on android, when user touch on screen,how we can get position touched ? :)

Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 11, 2015, 06:40:52 pm
@ Jmpessoa

Thank you. Fixed sample. Going to fix the real application.

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 11, 2015, 11:20:51 pm
@ Jmpessoa

What happened with the fontsize property?

fontsize=17.  :o

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on July 12, 2015, 01:47:26 am
@m4u_hoahoctro

1. we can not change GUI controls inside "AsyncTask OnDoInBackground":

Code: [Select]
procedure TAndroidModule1.jAsyncTask1DoInBackground(Sender: TObject;
  progress: integer; out keepInBackground: boolean);
begin   
    .....
    FImageBitmap:= jImageFileManager1.LoadFromURL('http://miftyisbored.com/wp-content/uploads/2013/07/nature-sound-spa-app.png'); //'http://i.imgur.com/n2lQnkI.png
    FImageBitmap:= Get_jObjGlobalRef(FImageBitmap);
    .....
end;

so, we need save  [jObject] "FImageBitmap" get from the Internet to set "jImageView" in other code place ... but
JNI/Java Native Interface forget the [jObject] "FImageBitmap" reference as soon as procedure "end;"

The solution is JNI "Get_jObjGlobalRef"  from "androidwidget.pas"

2. OnTouch is  implemented [at the moment] at least in "jView" and "jSurfaceView"

code example:

Code: [Select]
procedure TAndroidModule1.jView1TouchDown(Sender: TObject; Touch: TMouch);
begin
   ShowMessage('Touch: X='+ FloatToStr(Touch.Pt.X) + ' Y='+FloatToStr(Touch.Pt.Y) );
end;

or

Code: [Select]
procedure TAndroidModule1.jSurfaceView1TouchDown(Sender: TObject; Touch: TMouch);
begin
   ShowMessage('Touch: X='+ FloatToStr(Touch.Pt.X) + ' Y='+FloatToStr(Touch.Pt.Y) );
end;


@rx3.fireproof

Yes, font size [behavior] changed! ...  sorry.... maybe, you need increased it...

[we were having a lot of problems with "jListView" item font size]

EDITED: fontsize = 0 --> default  size!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 12, 2015, 03:03:44 pm
@jmpessoa

Can we implement download file function  to phone ?
And about loading video + mp3 file with jmediaplayer and jsurfaceview : Video and mp3 ( from links on internet ) are downloaded to phone cache first and then played or loading and playing at the same time ?

thanks
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 12, 2015, 03:24:33 pm
@jmpessoa

To increase the size impossible. Problems with design time and emulator.

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 12, 2015, 03:28:26 pm
If the fontsize=0.
   
The visual size of the font on device for jtextview less than for the jedittext.
      
The font size is smaller than necessary.

Use a Lawn impossible. Please return the good fontsize.
 

With Respect

rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on July 12, 2015, 04:04:08 pm
@rx3.fireproof

Quote
If the fontsize=0.
The visual size of the font on device for jtextview less than for the jedittext. ...

Yes,  this is default for android.... try  increase only jtextview font ....

Ok, I will do a patch to configure "old" mode ... please,  wait some minutes ..

Thank you!

Edited: Done! go to github!

You can use new "SetChangeFontSizeByComplexUnitPixel(False)"  to get the old
behaviour/mode!  [jtextview and jEditTex]

maybe you will need do "Lazarus IDE --> Run --> Clean up and Build"  ...

Edited:

@m4u_hoahoctro

Quote
Can we implement download file function to phone ?

Yes,  what file type? I can do a demo.... [to download  "txt" use jTextFileManager and for "image" file use jImageFileManager]

Quote
And about loading video + mp3 file with jmediaplayer and jsurfaceview : Video and mp3 ( from links on internet ) are downloaded to phone cache first and then played or loading and playing at the same time ?

cached first ...
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 12, 2015, 05:23:45 pm
@jmpessoa


You can use new "SetChangeFontSizeByComplexUnitPixel(False)"  to get the old
behaviour/mode!  [jtextview and jEditTex]

maybe you will need do "Lazarus IDE --> Run --> Clean up and Build"  ...

    
In the program I use the jlistview, jspinner, jcheckbox, jbutton.  How to be with them?

With Respect
rx3.fireproof

 
Title: Re: Android Module Wizard
Post by: jmpessoa on July 12, 2015, 05:27:58 pm
Ok ... some minutes ... :D


Edited: Done! go to github!

Added method "SetChangeFontSizeByComplexUnitPixel"
to jListView,  jButton,  jRadioButton,  jCheckBox,  jSpinner,  jGridView,  jDigitalClock

default = True !

so, you need: SetChangeFontSizeByComplexUnitPixel(False)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 12, 2015, 05:30:52 pm

Quote
@m4u_hoahoctro

Quote
Can we implement download file function to phone ?

Yes,  what file type? I can do a demo.... [to download  "txt" use jTextFileManager and for "image" file use jImageFileManager]



Yes,plese do. There are many things I need study more  :D
and Is it available for type ".mp3" and ".mp4" ?  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on July 12, 2015, 06:44:12 pm
@m4u_hoahoctro

Ok I will do some demos ....


@rx3.fireproof  ;D  Done! go to github!

edited: please,  a minute... I forgot to "published" the property!

edited: Ok! property "FontSizeByComplexUnitPixel" is "published" now! Please, go to github :)
Title: Re: Android Module Wizard
Post by: jmpessoa on July 12, 2015, 08:02:24 pm
@Leledumbo

Quote
... Save cookie is be the key...

Ok, I done some implementation ... but I test only with "http://www.google.com/" ...

Can you implement/provide a minimalistic server side?
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 13, 2015, 12:40:42 pm
    
@jmpessoa

FontSizeByComplexUnitPixel only works for  jListView,  jSpinner on real device.    
For jtextview and jEditTex not working. SetChangeFontSizeByComplexUnitPixel(False)  not working to.

For jtextview  SetChangeFontSizeByComplexUnitPixel is absent.

With Respect
rx3.fireproof

ps AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Title: Re: Android Module Wizard
Post by: Leledumbo on July 13, 2015, 01:44:51 pm
@Leledumbo

Quote
... Save cookie is be the key...

Ok, I done some implementation ... but I test only with "http://www.google.com/" ...

Can you implement/provide a minimalistic server side?
I can provide a fpweb sample that you can run as a standalone app accessible from your localhost. Give me some time.
Title: Re: Android Module Wizard
Post by: jmpessoa on July 13, 2015, 09:36:02 pm
@ rx3.fireproof

1. for simplicity and quickness  [at the moment], we are trying improve it only  in "run time" [real device]

2.

Quote
For jtextview  SetChangeFontSizeByComplexUnitPixel is absent....

where?  in "code" ? [my system is ok ... github too!]

-----------

@Leledumbo

ok!


 
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 13, 2015, 10:42:36 pm
@jmpessoa

Code: [Select]

procedure TAndroidModule2.AndroidModule2JNIPrompt(Sender: TObject);

begin

  jedittext5.FontSizeByComplexUnitPixel:=false;
  jlistview1.FontSizeByComplexUnitPixel:=false;

  jspinner1.FontSizeByComplexUnitPixel:=false;
  jspinner2.FontSizeByComplexUnitPixel:=false;

  jtextview1.FontSizeByComplexUnitPixel:=false;
  jtextview2.FontSizeByComplexUnitPixel:=false;
  jtextview3.FontSizeByComplexUnitPixel:=false;
  jtextview4.FontSizeByComplexUnitPixel:=false;
  jtextview7.FontSizeByComplexUnitPixel:=false;
  jtextview5.FontSizeByComplexUnitPixel:=false;
  jtextview6.FontSizeByComplexUnitPixel:=false;

  jedittext1.FontSizeByComplexUnitPixel:=false;
  jedittext2.FontSizeByComplexUnitPixel:=false;
  jedittext3.FontSizeByComplexUnitPixel:=false;
  jedittext4.FontSizeByComplexUnitPixel:=false;
  jedittext7.FontSizeByComplexUnitPixel:=false;   

  end;


With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on July 14, 2015, 12:05:31 am
@rx3.fireproof

Ok, I understood! I will see what can be improved .... at the moment just set the property "FontSizeByComplexUnitPixel" to "False" in object inspector [not in OnJNIPrompt], so, I think, you can fix your code!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on July 14, 2015, 09:58:41 am
Hi!

There is an updated Lamw revision.

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 34 - 14 July 2015 -

   IMPROVEMENTS!   

          jHttpClient component:   
      
         New! Added Cookie Support [need tests !!]: // <<--- @Leledumbo's request and suggestion!    

   NEW!
      AppHttpClientCookiesDemo1

   LOST! [sorry ..] 

      FontSizeByComplexUnitPixel component property was lost!   //<<--many problems !!
   
   NEW!
      FontSizeUnit component property [ unitDefault  <--> unitScaledPixel ]

      Hint:  try FontSizeUnit=unitPixel [jListView and jSpinner more responsive] and better developer experience!

   HINT 1: Old Projects: upgrade your projects code templates !
         Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!
         [After any form/component/property  changed and saved the problem gets solved!]


Thanks to All!
Title: Re: Android Module Wizard
Post by: Leledumbo on July 14, 2015, 12:24:45 pm
@Leledumbo

ok!
Sorry for taking a long time. This is an embedded http server fpweb app on port 8080 (install weblaz to compile on lazarus), you can just run it from terminal then type http://localhost:8080<request> in the address bar. Valid requests are: /cookie/set & cookie/get. Cookie expires 1 minute after set. Note that the expiration time is in GMT so your browser might wrongly interpret it if the timezone is not the same.

To validate:
/cookie/get -> Cookie get:
/cookie/set -> Cookie set: somevalue
/cookie/get -> Cookie get: somevalue
wait for 1 minute
/cookie/get -> Cookie get:
Title: Re: Android Module Wizard
Post by: rx3.fireproof on July 14, 2015, 03:15:53 pm
@jmpessoa

Everything works. Thank you very much.

With Respect
rx3.fireproof
Title: Re: Android Module Wizard
Post by: jmpessoa on July 14, 2015, 05:40:12 pm
@Leledumbo

Ok! I will test it.

Note: As soon as the requisites are addressed I will implement
the Asyncs versions:  "GetStatefulAsync" and "PostStatefulAsync"
and a better "header"  support....

Thank you!

@ rx3.fireproof

Good!!!! Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 15, 2015, 10:59:30 am
@m4u_hoahoctro

Ok I will do some demos ....


ok  :)
Title: Re: Android Module Wizard
Post by: renabor on July 15, 2015, 06:36:15 pm
Hello @jmpessoa!

I have found 2 bug, first regards ShowCustomMessage, that is declared overload but different:

Code: [Select]
procedure ShowCustomMessage(_layout: jObject; _gravity: integer; _lenghTimeSecond: integer); overload;     
should be:
procedure ShowCustomMessage(_layout: jObject; _gravity: TGravity; _lenghTimeSecond: integer); overload; 

the last is related to jListView and ItemIndex.
You have removed all Events related to ClickCaption, but in source more and more reference to Caption are creating to me many problems.
Items in my ListView are complex, so in my application Caption isn't a string and I can't get ItemIndex!
I suppose that all reference to Caption in all functions related to Click Event are useless and can safely be removed.

I hope you can help me
best regards
Title: Re: Android Module Wizard
Post by: jmpessoa on July 16, 2015, 02:46:13 am
Hello @renabor!


1. Ok,  ShowCustomMessage fixed! Thank you!

2.
Quote
...so in my application Caption isn't a string and I can't get ItemIndex

Code: [Select]
  jListView = class(jVisualControl)
  private
      FOnClickItem  : TOnClickCaptionItem;
      .....

Here is the  "new" OnClickItem  signature:   [we stayed with the old "OnClickCaptionItem" signature ]

Code: [Select]
TOnClickCaptionItem= Procedure(Sender: TObject; itemIndex: integer; itemCaption: string) of object;


Here the generated code:

Code: [Select]
procedure TAndroidModule1.jListView1ClickItem(Sender: TObject; itemIndex: integer; itemCaption: string);
begin
   
end;


Mybe your need update "OnClickItem " generated code ... [or, maybe, I did not understand your problem ....]

EDITED: or "Click" is not fired?

EDITED: Please, change jListView [Controls.java] :

Code: [Select]
controls.pOnClickCaptionItem(PasObj, (int)position , alist.get((int)position).label);

change to:

Code: [Select]
controls.pOnClickCaptionItem(PasObj, (int)id , alist.get((int)id).label);

 (int)position changed to  (int)id

[solved?]

3.
Quote
...I hope you can help me

Yes, we will endeavor to find a solution!

off topic: Please, help me in "jHttpClient" [new] cookies!   How? test and patch it!
Title: Re: Android Module Wizard
Post by: renabor on July 16, 2015, 09:06:18 am
@jmpessoa

Yes, problem is that click is fired correctly java-side but OnClickItem are not.
Here all corrections made to source
Code: [Select]
//////////////////////
Laz_and_Controls.pas
//////////////////////

    //FOnClickItem  : TOnClickCaptionItem;
    FOnClickItem  : TOnClickItem;

    //FOnLongClickItem:  TOnClickCaptionItem;
    FOnLongClickItem:  TOnClickItem;     

    //procedure GenEvent_OnClickCaptionItem(Obj: TObject; index: integer; caption: string); // <<<<---- using caption here is useless but generate the error
    procedure GenEvent_OnClickItem(Obj: TObject; index: integer); //renabor

    //procedure GenEvent_OnLongClickCaptionItem(Obj: TObject; index: integer; caption: string);
    procedure GenEvent_OnLongClickItem(Obj: TObject; index: integer); // renabor   

   //Procedure Java_Event_pOnClickCaptionItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer; caption: JString);
   Procedure Java_Event_pOnClickItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer); // renabor

   //Procedure Java_Event_pOnListViewLongClickCaptionItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer; caption: JString);
   Procedure Java_Event_pOnListViewLongClickItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer); // renabor   


//Procedure Java_Event_pOnClickCaptionItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer; caption: JString);
Procedure Java_Event_pOnClickItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer);
var
//   pasCaption: string;
 _jBoolean: JBoolean;
begin
  gApp.Jni.jEnv:= env;
  gApp.Jni.jThis:= this;

  if Obj is jListVIew then
  begin
    jForm(jListVIew(Obj).Owner).UpdateJNI(gApp);
(*    pasCaption := '';
    if caption <> nil then
    begin
      _jBoolean:= JNI_False;
      pasCaption:= string( env^.GetStringUTFChars(env,caption,@_jBoolean) );
    end;*)
    //jListVIew(Obj).GenEvent_OnClickCaptionItem(Obj, index, pasCaption);
    jListVIew(Obj).GenEvent_OnClickItem(Obj, index); // renabor
  end;
end; 

//Procedure Java_Event_pOnListViewLongClickCaptionItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer; caption: JString);
Procedure Java_Event_pOnListViewLongClickItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer);
var
//   pasCaption: string;
 _jBoolean: JBoolean;
begin
  gApp.Jni.jEnv:= env;
  gApp.Jni.jThis:= this;

  if Obj is jListVIew then
  begin
    jForm(jListVIew(Obj).Owner).UpdateJNI(gApp);
(*    pasCaption := '';
    if caption <> nil then
    begin
      _jBoolean:= JNI_False;
      pasCaption:= string( env^.GetStringUTFChars(env,caption,@_jBoolean) );
    end;*)
//    jListVIew(Obj).GenEvent_OnLongClickCaptionItem(Obj, index, pasCaption);
    jListVIew(Obj).GenEvent_OnLongClickItem(Obj, index); // renabor
  end;
end; 

//Procedure jListView.GenEvent_OnClickCaptionItem(Obj: TObject; index: integer;  caption: string);
Procedure jListView.GenEvent_OnClickItem(Obj: TObject; index: integer);
begin
  //if Assigned(FOnClickItem) then FOnClickItem(Obj,index, caption); 
  if Assigned(FOnClickItem) then FOnClickItem(Obj,index); // renabor
end;   

//procedure jListView.GenEvent_OnLongClickCaptionItem(Obj: TObject; index: integer; caption: string);
procedure jListView.GenEvent_OnLongClickItem(Obj: TObject; index: integer);
begin
//  if Assigned(FOnLongClickItem) then FOnLongClickItem(Obj,index,caption);// renabor
   if Assigned(FOnLongClickItem) then FOnLongClickItem(Obj,index);
end;           


//////////////////
plainwidget.pas
/////////////////

//TOnClickCaptionItem= Procedure(Sender: TObject; Item: integer; caption: string) of object; // renabor

/////////////////
Controls.lpr
////////////////

  //pOnClickCaptionItem name 'Java_com_suevoz_borsa_Controls_pOnClickCaptionItem',
  pOnClickItem name 'Java_com_suevoz_borsa_Controls_pOnClickItem', // renabor
  //pOnListViewLongClickCaptionItem name 'Java_com_suevoz_borsa_Controls_pOnListViewLongClickCaptionItem',
  pOnListViewLongClickItem name 'Java_com_suevoz_borsa_Controls_pOnListViewLongClickItem', // renabor

{ Class:     com_suevoz_borsa_Controls
  Method:    pOnClickItem
  Signature: (JI)V }
procedure pOnClickItem(PEnv: PJNIEnv; this: JObject; pasobj: JLong; position: JInt); cdecl; // renabor
begin
  Java_Event_pOnClickItem(PEnv,this,TObject(pasobj),position);
end;


{ Class:     com_suevoz_borsa_Controls
  Method:    pOnListViewLongClickItem
  Signature: (JI)V }
procedure pOnListViewLongClickItem(PEnv: PJNIEnv; this: JObject; pasobj: JLong; position: JInt); cdecl; // renabor
begin
  Java_Event_pOnListViewLongClickItem(PEnv,this,TObject(pasobj),position);
end;

   (name:'pOnClickItem';
    signature:'(JI)V'; // renabor
    fnPtr:@pOnClickItem;),

    (name:'pOnListViewLongClickItem';
    signature:'(JI)V'; // renabor
    fnPtr:@pOnListViewLongClickItem;),

////////////////////
Controls.java
///////////////////

Class jListView

public static boolean isEmpty(ArrayList coll) {
return (coll == null || coll.isEmpty());
}

this.onItemClickListener = new OnItemClickListener() {
@Override
public  void onItemClick(AdapterView<?> parent, View v, int position, long id) {
if (!isEmpty(alist)) {
if (highLightSelectedItem) {
if (lastSelectedItem > -1) {
DoHighlight(lastSelectedItem, textColor);    
}    
DoHighlight(position, highLightColor);
}
if (alist.get(position).widget == 2 /*radio*/) { //fix 16-febr-2015
for (int i=0; i < alist.size(); i++) {
alist.get(i).checked = false;
}
alist.get(position).checked = true;
aadapter.notifyDataSetChanged();
}    

selectedItemCaption = alist.get((int)position).label;
//controls.pOnClickCaptionItem(PasObj, (int)position , alist.get((int)position).label);
controls.pOnClickItem(PasObj, (int)position ); //renabor
}
lastSelectedItem = (int)position;
}
};

this.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (!isEmpty(alist)) {
selectedItemCaption = alist.get((int)position).label;
//controls.pOnListViewLongClickCaptionItem(PasObj, (int)position , alist.get((int)position).label);
controls.pOnListViewLongClickItem(PasObj, (int)position ); // renabor
return false;
}
lastSelectedItem = (int)position;
Log.i("lastSelectedItem",String.valueOf(lastSelectedItem));
return false;
}
});

// public  native void pOnClickCaptionItem(long pasobj, int position, String caption);
public  native void pOnClickItem(long pasobj, int position); // renabor
// public  native void pOnListViewLongClickCaptionItem(long pasobj, int position, String caption);
public  native void pOnListViewLongClickItem(long pasobj, int position); // renabor


I use an Adapter and a List not standard:

      if(this.getAdapter() != optitListAdapter ) {  this.setAdapter(optitListAdapter); }
      optitListAdapter.notifyDataSetChanged();

and therefore I must test if alist is empty or not.
I have removed all reference to Caption but can't resolve this error:
Code: [Select]
W/dalvikvm( 9411): JNI WARNING: NewStringUTF input is not valid Modified UTF-8: illegal continuation byte 0x2
W/dalvikvm( 9411):              string: '@-�@��@0-�'
W/dalvikvm( 9411):              in Lcom/suevoz/borsa/Controls;.pOnClickItem:(JI)V (NewStringUTF)
I/dalvikvm( 9411): "main" prio=5 tid=1 NATIVE
I/dalvikvm( 9411):   | group="main" sCount=0 dsCount=0 obj=0x41d61ea0 self=0x41d50258
I/dalvikvm( 9411):   | sysTid=9411 nice=-11 sched=0/0 cgrp=apps handle=1073860948
I/dalvikvm( 9411):   | state=R schedstat=( 0 0 0 ) utm=81 stm=25 core=0
I/dalvikvm( 9411):   #00  pc 0000132e  /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
I/dalvikvm( 9411):   #01  pc 00064086  /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+33)
I/dalvikvm( 9411):   #02  pc 00058060  /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+395)
I/dalvikvm( 9411):   #03  pc 000580ce  /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
I/dalvikvm( 9411):   #04  pc 0003c03c  /system/lib/libdvm.so
I/dalvikvm( 9411):   #05  pc 0003d474  /system/lib/libdvm.so
I/dalvikvm( 9411):   #06  pc 0003f846  /system/lib/libdvm.so
I/dalvikvm( 9411):   at com.suevoz.borsa.Controls.pOnClickItem(Native Method)
I/dalvikvm( 9411):   at com.suevoz.borsa.jListView$1.onItemClick(Controls.java:3140)
I/dalvikvm( 9411):   at android.widget.AdapterView.performItemClick(AdapterView.java:308)
I/dalvikvm( 9411):   at android.widget.AbsListView.performItemClick(AbsListView.java:1495)
I/dalvikvm( 9411):   at android.widget.AbsListView$PerformClick.run(AbsListView.java:3453)
I/dalvikvm( 9411):   at android.widget.AbsListView$3.run(AbsListView.java:4816)

Thank you!

I will give a try to cookies ...

EDIT:
There is a new strange error when creating a new program (Lamw GUI):

>>>>>>>>>>     Unable to create file "cookies/build-debug.bat"

and recompiling apphttpclientcookiesdemo I get this error:
Code: [Select]
W/dalvikvm(27477): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/apphttpclientcookiesdemo1/Controls;
D/AndroidRuntime(27477): Shutting down VM
W/dalvikvm(27477): threadid=1: thread exiting with uncaught exception (group=0x41d60da0)
W/ActivityManager(  737): Permission Denial: getCurrentUser() from pid=27477, uid=10503 requires android.permission.INTERACT_ACROSS_USERS
E/AndroidRuntime(27477): FATAL EXCEPTION: main
E/AndroidRuntime(27477): Process: com.example.apphttpclientcookiesdemo1, PID: 27477
E/AndroidRuntime(27477): java.lang.UnsatisfiedLinkError: Couldn't load controls from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.apphttpclientcookiesdemo1-1.apk,libraryPath=/data/app-lib/com.example.apphttpclientcookiesdemo1-1]: findLibrary returned null
E/AndroidRuntime(27477): at java.lang.Runtime.loadLibrary(Runtime.java:358)
E/AndroidRuntime(27477): at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime(27477): at com.example.apphttpclientcookiesdemo1.Controls.<clinit>(Controls.java:15553)
E/AndroidRuntime(27477): at com.example.apphttpclientcookiesdemo1.App.onCreate(App.java:65)
E/AndroidRuntime(27477): at android.app.Activity.performCreate(Activity.java:5451)
Title: Re: Android Module Wizard
Post by: jmpessoa on July 16, 2015, 07:14:58 pm
@renabor

1. About signature with "caption" or without "caption"....

I just do [now!] a minor change in  jListItemRow [Controls.java]  [revision 34.2]

set
Code: [Select]
label = "";
in constructor

I not see a problem in having a parameter [label] extra .... you can do your label = ""

2. The change  (int)position to  (int)id  can solve some custom row ... [done in revision 34.1]

3. I think your problem begin with a  project outdated , after some revision ...

Please, we will follow the following guide:

I. save yours specifcs java code  [Controls.java]

II. upgrate from github ..[now!].

III. From Lazarus IDE ---> Tools ---> [Lamw] Android Module  Wizard ---> Upgrade Code Templates [all!]

IV. Now, you have a problem!

you old/original "OnClickItem" signature lost the compatibility!

yes, the old signature not have "caption"!

but your can see in your new genereted "controls.lpr" code:

Code: [Select]
procedure pOnClickCaptionItem(PEnv: PJNIEnv; this: JObject; pasobj: JLong; position: JInt; caption: JString); cdecl;
begin
  Java_Event_pOnClickCaptionItem(PEnv,this,TObject(pasobj),position,caption);
end;

and here is a coherent implementation:

Code: [Select]
Procedure Java_Event_pOnClickCaptionItem(env: PJNIEnv; this: jobject; Obj: TObject;index: integer; caption: JString);
var
   pasCaption: string;
 _jBoolean: JBoolean;
begin
  gApp.Jni.jEnv:= env;
  gApp.Jni.jThis:= this;

  if Obj is jListVIew then
  begin
    jForm(jListVIew(Obj).Owner).UpdateJNI(gApp);
    pasCaption := '';
    if caption <> nil then
    begin
      _jBoolean:= JNI_False;
      pasCaption:= string( env^.GetStringUTFChars(env,caption,@_jBoolean) );
    end;
    jListVIew(Obj).GenEvent_OnClickCaptionItem(Obj, index, pasCaption);
  end;
end;

and and here is a coherent definition:

Code: [Select]
  jListView = class(jVisualControl)
      FOnClickItem  : TOnClickCaptionItem; 
  private
  ...................
  protected
      procedure GenEvent_OnClickCaptionItem(Obj: TObject; index: integer; caption: string);
   ....................
  end;

where is defined:

Code: [Select]
TOnClickCaptionItem= Procedure(Sender: TObject; itemIndex: integer; itemCaption: string) of object;

lastly:

Code: [Select]
Procedure jListView.GenEvent_OnClickCaptionItem(Obj: TObject; index: integer;  caption: string);
begin
  if Assigned(FOnClickItem) then FOnClickItem(Obj,index, caption);
end;

But you old/original "OnClickItem" has signature (Obj,index) ..... and fail!

Solution:

Get a new signature from Object Inspector to "OnClickItem" event

and copy your code to "new" OnClickItem.... just change your old "Item/integer" param to "itemIndex/integer"

and from that point we will try to find why we still have some bugs!  :D

Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 18, 2015, 04:16:01 pm
Hi jmpessoa

I want from androidmodule 2 I can come back to androidmodule1
On the button of androidmodule2 i put this code

Code: [Select]
gapp.CreateForm(tandroidmodule1,androidmodule1);
  androidmodule1.Init(gapp);
  androidmodule1.show;
  androidmodule2.finish;       

but when pressing it, the app auto closes
I am using Genymotion v2.4
Title: Re: Android Module Wizard
Post by: renabor on July 18, 2015, 04:32:11 pm
Hello @jmpessoa!

Here the solution (finally!) to my problem with click lost on jListView with custom adapter. Problem was related to code that accessed to alist even if was empty in onItemClickListener and the basic hack is to call controls.pOnClickCaptionItem(PasObj, lastSelectedItem, "") with a empty Caption (last parameter) and check with isEmpty if alist is or not empty.

Code: [Select]
/////////////////
Controls.java
////////////////
onItemClickListener = new OnItemClickListener() {@Override
public void onItemClick(AdapterView <? > parent, View v, int position, long id) {
lastSelectedItem = (int) position;
if (!isEmpty(alist)) { // this test is necessary !
if (highLightSelectedItem) {
if (lastSelectedItem > -1) {
DoHighlight(lastSelectedItem, textColor);
}
DoHighlight((int) id, highLightColor);
}
if (alist.get((int) id).widget == 2 /*radio*/ ) { //fix 16-febr-2015
for (int i = 0; i < alist.size(); i++) {
alist.get(i).checked = false;
}
alist.get((int) id).checked = true;
aadapter.notifyDataSetChanged();
}
controls.pOnClickCaptionItem(PasObj, (int) id, alist.get((int) id).label);
} else {
controls.pOnClickCaptionItem(PasObj, lastSelectedItem, ""); // avoid passing possibly undefined Caption
}
}
};

this.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {@Override
public boolean onItemLongClick(AdapterView <? > parent, View view, int position, long id) {
if (!isEmpty(alist)) {
selectedItemCaption = alist.get((int) id).label;
controls.pOnListViewLongClickCaptionItem(PasObj, (int) id, alist.get((int) id).label);
return false;
}
lastSelectedItem = (int) id;
return false;
}
});

}
public static boolean isEmpty(ArrayList coll) {
return (coll == null || coll.isEmpty());
}

p.s. I think that method jFree must set setOnItemLongClickListener(null) too

New method jHttpClient.DeleteStateful

The method implements the DELETE with 2 parameter: Url and Value.
Useful for REST server that will receive a call like this, made with DELETE method:

http://Url/Value

Code: [Select]
/////////////////
Laz_And_Controls
////////////////
function DeleteStateful(_url: string; _value:string): string;

function jHttpClient.DeleteStateful(_url, _value:string): string;
begin
  //in designing component state: result value here...
  if FInitialized then
   Result:= jHttpClient_DeleteStateful(FjEnv, FjObject, _url, _value);
end;   

/////////////////
And_jni_bridge
////////////////
function jHttpClient_DeleteStateful(env: PJNIEnv; _jhttpclient: JObject; _url, _value: string): string;

function jHttpClient_DeleteStateful(env: PJNIEnv; _jhttpclient: JObject; _url, _value: string): string;
var
  jStr: JString;
  jBoo: JBoolean;
  jParams: array[0..1] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jParams[0].l:= env^.NewStringUTF(env, PChar(_url));
  jParams[1].l:= env^.NewStringUTF(env, PChar(_value));
  jCls:= env^.GetObjectClass(env, _jhttpclient);
  jMethod:= env^.GetMethodID(env, jCls, 'DeleteStateful', '(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;');
  jStr:= env^.CallObjectMethodA(env, _jhttpclient, jMethod, @jParams);
  case jStr = nil of
     True : Result:= '';
     False: begin
              jBoo:= JNI_False;
              Result:= string( env^.GetStringUTFChars(env, jStr, @jBoo));
            end;
  end;
  env^.DeleteLocalRef(env,jParams[0].l);
  env^.DeleteLocalRef(env,jParams[1].l);
  env^.DeleteLocalRef(env, jCls);
end;

/////////////////
Controls.java
////////////////

import org.apache.http.client.methods.HttpDelete;

    public String DeleteStateful(String _url, String _value) throws Exception {

    int statusCode = 0;
    String strResult = "";

    HttpParams httpParams = new BasicHttpParams();
    int connection_Timeout = 5000;
    HttpConnectionParams.setConnectionTimeout(httpParams, connection_Timeout);
    HttpConnectionParams.setSoTimeout(httpParams, connection_Timeout);

    HttpDelete httpDelete = new HttpDelete(_url + "/" + _value);

    if (mAuthenticationMode != 0) {
    String _credentials = mUSERNAME + ":" + mPASSWORD;
    String _base64EncodedCredentials = Base64.encodeToString(_credentials.getBytes(), Base64.NO_WRAP);
    httpDelete.addHeader("Authorization", "Basic " + _base64EncodedCredentials);
    }

    HttpResponse response = client2.execute(httpDelete, localContext);
    HttpEntity entity = response.getEntity();

    StatusLine statusLine = response.getStatusLine();
    statusCode = statusLine.getStatusCode();

    if (statusCode == 200) { //OK       
    entity = response.getEntity();
    if (entity != null) {
    strResult = EntityUtils.toString(entity);
    }
    }
    return strResult;
    }

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on July 18, 2015, 10:00:38 pm

@ renabor

I will make these patches!

Thank you!
Title: Re: Android Module Wizard
Post by: liuzg2 on July 24, 2015, 04:20:24 pm
how to call  a webservice
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 25, 2015, 11:11:56 am
how to call  a webservice

Can explain more ? What exactly do you want ? load a website ?
Title: Re: Android Module Wizard
Post by: Leledumbo on July 25, 2015, 08:27:12 pm
I just tried the NoGUI and it seems broken. There are at least 3 scenarios, all after filling the initial dialog:
Could you test?
Title: Re: Android Module Wizard
Post by: jmpessoa on July 25, 2015, 08:47:20 pm

@ Leledumbo,

Ok, I will test and fix NoGUI.

Thank you!
Title: Re: Android Module Wizard
Post by: renabor on July 27, 2015, 07:45:30 am
Hello @jmpessoa!

I'm trying to use jImageBtn in order to replace normal buttons but can't find the right road.
Which is correct method to load an image as background resource  in jImageBtn?
The sample jImageBtn in AppMenuDemo won't work.
My intent is to replace all buttons with jImageBtn loaded with images taken from Android icons pack in material style (rounded).

Same trouble changing backgroundcolor of a Form or Panel. Changin color from palette work, but it where very nice changing backgroundcolor loading directly the color resource into color settings, using name, not numeric representation.

It is possible to change font for entire App?

A minor typo in jPanel. Having an object inside it (i.e. jEditText), his property MarginBottom is not read and has no effect.

Have you plan to add the Navigation Drawer and Floating Action Button?

Thank you!

Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 27, 2015, 11:47:04 am
Hello @jmpessoa!

I'm trying to use jImageBtn in order to replace normal buttons but can't find the right road.
Which is correct method to load an image as background resource  in jImageBtn?
The sample jImageBtn in AppMenuDemo won't work.
My intent is to replace all buttons with jImageBtn loaded with images taken from Android icons pack in material style (rounded).


Same trouble changing backgroundcolor of a Form or Panel. Changin color from palette work, but it where very nice changing backgroundcolor loading directly the color resource into color settings, using name, not numeric representation.

It is possible to change font for entire App?

A minor typo in jPanel. Having an object inside it (i.e. jEditText), his property MarginBottom is not read and has no effect.

Have you plan to add the Navigation Drawer and Floating Action Button?

Thank you!

may be using bitmap for imagebutton  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on July 29, 2015, 01:32:47 pm
Hello All!

There is an updated Lamw/Lazarus Android Module Wizard revision!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 35 - 28 July 2015 -

   IMPROVEMENT/FIXED!   

          jBluetoothClientSocket component <<--- @Euller and @osvaldotcf request!
               jBluetoothServerSocket component <<--- @Euller and @osvaldotcf request!             
               

   NEW Demos!
 
                AppBluetoothServerSocketDemo1 <---> AppBluetoothClientSocketDemo1 //<<--- No header

                AppBluetoothServerSocketDemo2 <---> AppBluetoothClientSocketDemo2 //<<--- header support

         Technical Notes [header support]:
            .Set property "DataHeaderReceiveEnable = True" for both [client/server]
            .Internal Format [yes, you can use without knowing this information!]:
               first two bytes: size of "header"
               following four bytes: size of "content"
               following bytes "dataHeader"
               following bytes "dataContent"
                  

   FIXED!  Target x86 [AndroidWizard_intf.pas]//<---- thanks to Takeda Matsuki.


   HINT 1: Old Projects: Please, upgrade your project code templates !
         Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!
         [After any form/component/property  changed and saved.... Problem solved!]

Thanks to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on July 30, 2015, 04:12:39 am
@jmpessoa

if load music or video from internet, they will be downloaded and saved to cache memory first, then played, we must wait some minutes if them have large size (>some megabytes)
So I want to ask do we can load and play at the same time ?  :)
Title: Re: Android Module Wizard
Post by: jc99 on August 01, 2015, 07:23:09 pm
@jmpessoa

As promissed:
The Wiki-Page:
http://wiki.freepascal.org/Talk:Android_tutorial (http://wiki.freepascal.org/Talk:Android_tutorial)
Maybe a LAMW-Wiki-Page could also help.
Title: Re: Android Module Wizard
Post by: renabor on August 02, 2015, 12:07:16 pm
@jmpessoa

With last revision, under Linux, it is still impossible to create a new Application.
Selecting JNI Android Module [Lamw GUI] from New menu the error message is:
"Unable to create file build-debug.bat"



Title: Re: Android Module Wizard
Post by: liuzg2 on August 03, 2015, 05:31:09 am
how to call  a webservice

Can explain more ? What exactly do you want ? load a website ?

ps: a  webservice server address   http://localhost:9001/Service/logon?wsdl
  then  client call    logon(name,password)
Title: Re: Android Module Wizard
Post by: renabor on August 03, 2015, 06:15:49 am
Hello liuzg2

Quote
ps: a  webservice server address   http://localhost:9001/Service/logon?wsdl
  then  client call    logon(name,password)

With jHttClient you have a full suite of opportunities:

Set authentication:

Code: [Select]
  jHttpClient1.SetAuthenticationHost('',-1);
  jHttpClient1.AuthenticationMode:=autBasic;   
  jHttpClient1.SetAuthenticationUser('username', 'password');

make a post:

Code: [Select]
  jHttpClient1.AddNameValueData('name','value');
  jHttpClient1.AddNameValueData('anothername','anothervalue');
  jHttpClient1.PostStateful('http://yourhost');   

using Get:

Code: [Select]
  string := jHttpClient1.Get('http://yourhost/getservice');

Call Delete method:

Code: [Select]
  jHttpClient1.DeleteStateful('http://yourhost','whattodelete');

See example in demos/Eclipse/AppHttpClientDemo1 too.

Best regards,
Title: Re: Android Module Wizard
Post by: jmpessoa on August 03, 2015, 07:27:05 am

Hello People!

within a few hours I will make an update to github, trying to solve some instability of lamw wizard
and jImageBtn ... [yes, the wizard lamw will become more smart!]

Thanks to All!
Title: Re: Android Module Wizard
Post by: renabor on August 03, 2015, 07:48:34 am

Hello People!

within a few hours I will make an update to github, trying to solve some instability of lamw wizard
and jImageBtn ... [yes, the wizard lamw will become more smart!]

Thanks to All!

Hello jmpessoa!

here some question related to jSqlite and Cursor .

freepascal don't permit to overload functions and procedure with same parameters, so

function jSqliteDataAccess.Select cannot be used!

Adding a second parameter to the procedure (i.e. gotolast: boolean def to false) can make possible to use the function Select.

In Controls there are some typos:
Code: [Select]
    public String SelectS(String selectQuery) { //return String
...
                    try
----->>>>>       this.cursor = null; // without this a second query will find the Cursor randomly positioned!!!

.............

    public void SelectV(String selectQuery) {   //just set the cursor! return void..
        this.cursor = null;
        try{         
        if (mydb!= null) {
           if (!mydb.isOpen()) {
              mydb = this.Open(); //controls.activity.openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
           }
        }                                
      this.cursor  = mydb.rawQuery(selectQuery, null);
----->>>>>>         this.cursor.moveToFirst();            
        mydb.close();        
     }catch(SQLiteException se){
         Log.e(getClass().getSimpleName(), "Could not select:" + selectQuery);
     }                      
}


thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on August 04, 2015, 06:36:12 am
Hi All!

There is an updated Lamw revision!

Version 0.6 - rev. 36 - 03 August 2015 -

   IMPROVEMENT!   

      Wizard forms usability [and code] redesigned!
         Eclipe/Ant project [finally] unified!
         Fixed [Lamw NoGUI] project //<<----Thanks to @leledumbo!          
               
   IMPROVEMENT!   

      jBluetooth
         News methods:
            PairDeviceByAddress
            UnpairDeviceByAddress
      
   FIXED! 

      jImageBtn //<<----Thanks to @renabor!         

      jSqliteDataAccess.Select //<<----Thanks to @renabor!

   NEW!
      "GET START" The Wiki-Page //<<----Thanks to @jc99!
         Ref. http://wiki.freepascal.org/Talk:Android_tutorial

            
   HINT 1: Old Projects: Please, upgrade your project code templates !
         Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!
         [After any form/component/property  changed and saved.... Problem solved!]

Thanks to All!  Special thanks to renabor, jc99 and leledumbo!

Title: Re: Android Module Wizard
Post by: Leledumbo on August 04, 2015, 07:49:32 am
Eclipe/Ant project [finally] unified!
Nice, less unneeded option since practically all Eclipse projects are Ant-compatible, just provide a proper build.xml.
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on August 05, 2015, 06:36:07 pm
Hi jmpessoa.

When i every open options menu and closed, menu item is adding same menu item to the options menu.

Thanks.
Title: Re: Android Module Wizard
Post by: renabor on August 06, 2015, 08:49:31 am
@jmpessoa

With last revision, under Linux, it is still impossible to create a new Application.
Selecting JNI Android Module [Lamw GUI] from New menu the error message is:
"Unable to create file build-debug.bat"

@jmpessoa

With new revision 36, on Linux, this problem is resolved, thank you!
Now compiling this is the error message:

Fatal: Cannot find unit system used from controls in LCLBase.

LCLBase is used only on Windows system and is not required on Linux.
Where do I find the reference to LCLBase?

Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on August 06, 2015, 04:53:38 pm
I can't use this code in lamw,app will close when I excute asynctask, I don't know why  :o . I am using unit fphttpclient

Code: [Select]
procedure TAndroidModule1.jAsyncTask1DoInBackground(Sender: TObject;
  progress: integer; out keepInBackground: boolean);
begin
 link:=trim(link);
 Try
 http1.HTTPMethod('GET',link,stream1,code);
 for i:=0 to http1.RequestHeaders.Count-1 do
 if pos('Location:',http1.ResponseHeaders.Strings[i])>0 then
 begin
 link:=StringReplace(trim(StringReplace(link,'Location:','',[])),' ','%20',[rfReplaceall]);
 for k:=length(link) downto 1 do if link[k]='/' then
 begin
 name:=copy(link,k,length(link)-k);
 break;
 end;
 stream2:=TFileStream.Create('/sdcard/'+name+'.mp3',fmcreate);
 http1.HTTPMethod('GET',link,stream1,code);
 stream1.Position:=0;
 stream2.CopyFrom(stream1,stream1.size);
 break;
 end;
 finally
   stream1.free;
   stream2.free;
   http1.free;
 end;
 keepinbackground:=false;
end;                   
Title: Re: Android Module Wizard
Post by: jmpessoa on August 06, 2015, 06:07:56 pm
@Fatih KILIÇ

Ok, I will do some test...

@renabor

LCLBase is need only to install components Icons as resource  [LResources.pas] ... but

a 'Lamw" cross-compile project do not need any reference to it!

@m4u_hoahoctro

Please, use jHttpClient! there some demo....
Title: Re: Android Module Wizard
Post by: renabor on August 06, 2015, 06:29:09 pm

@renabor

LCLBase is need only to install components Icons as resource  [LResources.pas] ... but

a 'Lamw" cross-compile project do not need any reference to it!

Yes, I guess it! but ... something where wrong creating a new App.
Here the code for unit1.pas
Code: [Select]
unit unit1;

{$mode delphi}

interface

uses
  Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
    Laz_And_Controls_Events, AndroidWidget;

type

  { TAndroidModule1 }

  TAndroidModule1 = class(jForm)
    jButton1: jButton;
   procedure jButton1Click(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
  end;

var
  AndroidModule1: TAndroidModule1;

implementation

{$R *.lfm}

{ TAndroidModule1 }

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
  ShowMessage('Hello World!');
end;

end.

[/quote]

and for unit1.lfm

Quote
object AndroidModule1: TAndroidModule1
  Left = 468
  Top = 260
  Width = 474
  Height = 442
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule1'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  object jEditText1: jEditText
    Left = 184
    Top = 80
    Width = 80
    Height = 39
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = []
    LayoutParamWidth = lpOneFifthOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'jEditText1'
    Alignment = taLeft
    InputTypeEx = itxText
    MaxTextLength = -1
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    HintTextColor = colbrSilver
    ScrollBarStyle = scrNone
    MaxLines = 1
    HorScrollBar = True
    VerScrollBar = True
    WrappingLine = False
    Editable = True
    FontSizeUnit = unitDefault
    Id = 0
  end
  object jButton1: jButton
    Left = 184
    Top = 144
    Width = 80
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = []
    LayoutParamWidth = lpOneFifthOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'jButton1'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    FontSizeUnit = unitDefault
    OnClick = jButton1Click
    Id = 0
  end
end
[/code]

All is ok, but it fail on compile, with error related to LCL.
Projects created with previous versions works fine and I can compile it without errors!

Title: Re: Android Module Wizard
Post by: jmpessoa on August 06, 2015, 09:55:30 pm

@renabor

few attempts:

1.may be accidentally your project became  LCL  dependent...
[Project --> Project Inspector ]

2.If you got an "old" project then try  "Run" -->> "Clean up and Bulid"

3. You can try open "tfpandroidbridge_pack.lpk" --->> "recompile clean" --->> Install


Title: Re: Android Module Wizard
Post by: jmpessoa on August 08, 2015, 09:52:03 pm
@Fatih KILIÇ

Quote
..When i every open options menu and closed, menu item is adding same menu item to the options menu...

I try some test ... and ... I do not have any problem...

You can get my test project here:

https://jmpessoa.opendrive.com/files?Ml85OTMxMzg2Nl9hbjR5bg

Can you post your project somewhere?

Thank you!
Title: Re: Android Module Wizard
Post by: Fatih KILIÇ on August 09, 2015, 09:42:10 am
Hi jmpessoa.

I created a new project now and tested again again, the error not occurs; Interesting   %). I am sorry.

Thank you.

Title: Re: Android Module Wizard
Post by: renabor on August 10, 2015, 03:41:23 pm

@renabor

few attempts:

1.may be accidentally your project became  LCL  dependent...
[Project --> Project Inspector ]

2.If you got an "old" project then try  "Run" -->> "Clean up and Bulid"

3. You can try open "tfpandroidbridge_pack.lpk" --->> "recompile clean" --->> Install

@jmpessoa, you are rigth! That was, nr 1!

And now some improvements to code, related with jListView.
Implementing a floating panel that can be used as a lateral menu, I haved problems with fling at panel level.
In my form I have a jPanel and over it a jListView. The onFling method is handled by jPanel but jListView intercept the Event and block it delegating his handling to parent ViewGroup, not to jPanel.
Solution was to add an TouchListener in jListView code.

Code: [Select]
private OnTouchListener onTouchListener;
private float mDownX = -1;
private float mDownY = -1;
private float pressure = 1;
private final float SCROLL_THRESHOLD = 10;
private boolean isOnClick;
private boolean canClick;

onTouchListener = new OnTouchListener() {@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction() & MotionEvent.ACTION_MASK;
switch (action) {
case MotionEvent.ACTION_DOWN:
canClick = false;
// Log.i("ACTION", "DOWN");
mDownX = event.getX();
mDownY = event.getY();
isOnClick = true; // blocco la propagazione
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (isOnClick) {
// Log.i("ACTION", "UP");
canClick = true;
} else {
//                                      Log.i("ACTION","UP NOT PROCESSED");
                                }
return false;
case MotionEvent.ACTION_MOVE:
if (isOnClick && (Math.abs(mDownX - event.getX()) > SCROLL_THRESHOLD || Math.abs(mDownY - event.getY()) > SCROLL_THRESHOLD)) {
// Log.i("ACTION", "MOVE");
isOnClick = false;
};
return false;
};
return false;
};
};
setOnTouchListener(onTouchListener);

and for better cooperation with OnClickListener, some addition to its implementation

Code: [Select]
onItemClickListener = new OnItemClickListener() {@Override
public void onItemClick(AdapterView <? > parent, View v, int position, long id) {
lastSelectedItem = (int) position;
--->>> if (canClick) {
// Log.i("ACTION", "CLICK");
if (!isEmpty(alist)) { // this test is necessary !  //  <----- thanks to @renabor
if (highLightSelectedItem) {
if (lastSelectedItem > -1) {
DoHighlight(lastSelectedItem, textColor);
}
DoHighlight((int) id, highLightColor);
}
if (alist.get((int) id).widget == 2) { //radio fix 16-febr-2015
for (int i = 0; i < alist.size(); i++) {
alist.get(i).checked = false;
}
alist.get((int) id).checked = true;
aadapter.notifyDataSetChanged();
}
controls.pOnClickCaptionItem(PasObj, (int) id, alist.get((int) id).label);
} else {
controls.pOnClickCaptionItem(PasObj, lastSelectedItem, ""); // avoid passing possibly undefined Caption
}
}
}
};
setOnItemClickListener(onItemClickListener);

and same to OnItemLongClickListener
Code: [Select]
this.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {@Override
public boolean onItemLongClick(AdapterView <?> parent, View view, int position, long id) {
--->>> if (canClick) {
if (!isEmpty(alist)) {  //  <----- thanks to @renabor
selectedItemCaption = alist.get((int) id).label;
controls.pOnListViewLongClickCaptionItem(PasObj, (int)id, alist.get((int)id).label);
return false;
};
lastSelectedItem = (int)id;
};
return false;
}
});

This post related to touch handling  is very interesting and has inspired me

http://www.codeproject.com/Articles/458042/Touch-handling-in-Android

Regards
Title: Re: Android Module Wizard
Post by: renabor on August 12, 2015, 12:32:59 pm
Hello @jmpessoa!

I need some helps.
Trying implementing FAB inside of jListView i'm unable to resolve 2 problems with image visualized.
Image appears and this is good, but centered in top of screen and not bottm right as I will.
And can't find a solution to inform my code that a click is succeded.
From pascal I use this line that works fine (source attached)

Code: [Select]
jListView1.SetFab(jImageFileManager1.LoadFromResources('ic_android'));

and this is code related added in Controls.java

Code: [Select]
public void setFab( android.view.ViewGroup viewgroup , Bitmap imageBmp) {
  ImageView imageView = new ImageView(ctx);
  imageView.setImageBitmap(imageBmp);
  imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
  viewgroup.addView(imageView);
       imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Log.i("FAB","CLICK");
controls.pOnClickFab(PasObj);
            }
        });
}

All works as expected, but when I click on Fab image I get this error:

Code: [Select]
E/art     ( 9774): No implementation found for void com.suevoz.borsa.Controls.pOnClickFab(long) (tried Java_com_suevoz_borsa_Controls_pOnClickFab and Java_com_suevoz_borsa_Controls_pOnClickFab__J)
E/AndroidRuntime( 9774): java.lang.UnsatisfiedLinkError: No implementation found for void com.suevoz.borsa.Controls.pOnClickFab(long) (tried Java_com_suevoz_borsa_Controls_pOnClickFab and Java_com_suevoz_borsa_Controls_pOnClickFab__J)

One solution I tried was such a method in constructor, but is not working:

Code: [Select]
onFabClickListener = new OnClickListener handleOnClick(final Button button) {
View.OnClickListener handleOnClick(final Button button) {
    return new View.OnClickListener() {
        public void onClick(View v) {
          controls.pOnClickFab(PasObj);
        }
    };
}
------------
public  native void pOnClickFab(long pasobj);

any idea?

Thank you in advance!
Title: Re: Android Module Wizard
Post by: jmpessoa on August 12, 2015, 07:57:31 pm
@renabor

1. Change here:

Code: [Select]
public void setFab(Bitmap imageBmp) {
  ImageView imageView = new ImageView(controls.activity);
  .....................
}

and Pascal side too!


2. what about "controls.pOnClickFab(PasObj)",  it is "well-defined"?

   2.1 you put a new entry in "ControlsEvents.txt"   -->>  "..\java" ?
         if true then --->> Lazarus IDE ---> Tools -->> Lamw ---> "upgrade code
templates"

             EDITED: You need put there  [ "..\java"] the your new "Controls.java"   too!!
Title: Re: Android Module Wizard
Post by: xinyiman on August 26, 2015, 06:24:17 pm
Solved my problem  when: sudo apt-get install gcc-arm-linux-androideabi




Hello , I'm trying to Install and configure everything on linux . He's following the lead

new_how_to_install_by_renabor.txt

but so far as to run the command me nuts , driving maybe not updated More ?

 make clean crossall OS_TARGET=android CPU_TARGET=arm

Code: [Select]
/usr/bin/ld: attenzione: link.res contiene sezioni di output; forse è stata dimenticata -T
make[2]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/utils/fpcm"
make rtl_clean FPC=/usr/share/fpcsrc/3.1.1/compiler/ppcrossarm
make[2]: ingresso nella directory "/usr/share/fpcsrc/3.1.1"
make -C rtl clean
make[3]: ingresso nella directory "/usr/share/fpcsrc/3.1.1/rtl"
/bin/rm -f fpcmade.arm-android Package.fpc ./ppas.sh script.res link.res 
/bin/rm -f *.s *_ppas.sh
make -C android clean
make[4]: ingresso nella directory "/usr/share/fpcsrc/3.1.1/rtl/android"
/bin/rm -f /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/prt0.o /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/dllprt0.o
/bin/rm -f /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/system.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/uuchar.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/unixtype.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/ctypes.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/baseunix.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/strings.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/objpas.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/macpas.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/iso7185.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/syscall.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/unixutil.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/fpintres.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/heaptrc.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/lineinfo.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/lnfodwrf.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/termio.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/unix.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/linux.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/initc.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cmem.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/linuxvcs.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/sysutils.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/typinfo.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/math.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/charset.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cpall.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/character.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/getopts.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/errors.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/dl.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/dynlibs.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/types.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/sysconst.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cthreads.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/classes.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/fgl.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/rtlconsts.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/dos.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cwstring.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/fpcylix.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/unixcp.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/fpwidestring.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/exeinfo.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1250.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1251.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1252.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1253.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1254.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1255.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1256.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1257.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp1258.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp437.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp646.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp850.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp856.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp866.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp874.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp8859_1.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp8859_5.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp8859_2.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/cp852.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/syslinux.ppu /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/linux.ppu
/bin/rm -f /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/math.rst /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/typinfo.rst /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/sysconst.rst /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/rtlconsts.rst
/bin/rm -f fpcmade.arm-android Package.fpc ./ppas.sh script.res link.res 
/bin/rm -f *.s *_ppas.sh
make[4]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/rtl/android"
make[3]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/rtl"
make[2]: uscita dalla directory "/usr/share/fpcsrc/3.1.1"
make packages_clean FPC=/usr/share/fpcsrc/3.1.1/compiler/ppcrossarm
make[2]: ingresso nella directory "/usr/share/fpcsrc/3.1.1"
make -C packages clean
make[3]: ingresso nella directory "/usr/share/fpcsrc/3.1.1/packages"
make -C fpmkunit clean_bootstrap
make[4]: ingresso nella directory "/usr/share/fpcsrc/3.1.1/packages/fpmkunit"
/bin/rm -rf units_bs
make[4]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/packages/fpmkunit"
make[3]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/packages"
make[2]: uscita dalla directory "/usr/share/fpcsrc/3.1.1"
make rtl_all FPC=/usr/share/fpcsrc/3.1.1/compiler/ppcrossarm FPCFPMAKE=/usr/share/fpcsrc/3.1.1/compiler/ppc RELEASE=1 'OPT='
make[2]: ingresso nella directory "/usr/share/fpcsrc/3.1.1"
make -C rtl all
make[3]: ingresso nella directory "/usr/share/fpcsrc/3.1.1/rtl"
make -C android all
make[4]: ingresso nella directory "/usr/share/fpcsrc/3.1.1/rtl/android"
/bin/mkdir -p /usr/share/fpcsrc/3.1.1/rtl/units/arm-android
arm-linux-androideabi-as  -o /usr/share/fpcsrc/3.1.1/rtl/units/arm-android/prt0.o arm/prt0.as
make[4]: arm-linux-androideabi-as: comando non trovato
Makefile:3487: set di istruzioni per l'obiettivo "prt0.o" non riuscito
make[4]: *** [prt0.o] Errore 127
make[4]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/rtl/android"
Makefile:2772: set di istruzioni per l'obiettivo "android_all" non riuscito
make[3]: *** [android_all] Errore 2
make[3]: uscita dalla directory "/usr/share/fpcsrc/3.1.1/rtl"
Makefile:2588: set di istruzioni per l'obiettivo "rtl_all" non riuscito
make[2]: *** [rtl_all] Errore 2
make[2]: uscita dalla directory "/usr/share/fpcsrc/3.1.1"
Makefile:2878: set di istruzioni per l'obiettivo "build-stamp.arm-android" non riuscito
make[1]: *** [build-stamp.arm-android] Errore 2
make[1]: uscita dalla directory "/usr/share/fpcsrc/3.1.1"
Makefile:2944: set di istruzioni per l'obiettivo "crossall" non riuscito
make: *** [crossall] Errore 2
Title: Re: Android Module Wizard
Post by: euller on August 26, 2015, 09:19:22 pm
Hello guys, does any of you has seen this error in your applications:

Code: [Select]
A/libc(30743): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
My application crashes, and logcat show this message, whenever I try to use jHttpClient.OnContentResult.

After some digging, I've found that after Android 4.0, they've changed the memory management and, most of JNI codes present this same kind of error. Does it makes sense also in LAMW?
Title: Re: Android Module Wizard
Post by: xinyiman on August 26, 2015, 10:29:38 pm
Hello , installing the package the nuts do Lazarus me this , why?

Compile package tfpandroidbridge_pack 0.0: Codice di uscita 1, Errori: 1
androidwidget.pas(15,44) Fatal: Impossibile trovare CustApp usato da AndroidWidget del pacchetto tfpandroidbridge_pack.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 27, 2015, 05:53:31 am
@Euller,

Quote
... I've found that after Android 4.0 ...

No, In my test, I compiled with android 4.2  [target 4.2, too], and it is ok!


@xinyiman

In my system the source of "CustApp" is in "C:\laz4android\fpc\x.y.z\source\packages\fcl-base\src"

and your "homemade" android cross-compile should generate "custapp.tpu" in "...\fpc\x.y.z\units\arm-android"

Title: Re: Android Module Wizard
Post by: xinyiman on August 27, 2015, 12:44:36 pm
@xinyiman

In my system the source of "CustApp" is in "C:\laz4android\fpc\x.y.z\source\packages\fcl-base\src"

and your "homemade" android cross-compile should generate "custapp.tpu" in "...\fpc\x.y.z\units\arm-android"


a question, this guide "new_how_to_install_by_renabor.txt"  is still valid and relevant to install everything on linux? Or it is partial and must follow another?
Title: Re: Android Module Wizard
Post by: renabor on August 27, 2015, 01:22:37 pm
Hello @xinyiman!

I've updated the guide, integrating it with more specific steps.
A note on fpc version, that must be 2.6.4 for compiling the trunk version (3.1.1).
If you have Ubuntu 14.04 (like me) you must download the correct version from here:
http://packages.ubuntu.com/vivid/fpc-2.6.4

Thank you!

#######################
(replace $HOME with your username)

################
install some necessary programs:

(CMD) sudo apt-get install android-tools-adb ant fp-compiler openjdk-7-jdk subversion

################
(CMD) mkdir ~/Android
(CMD) cd ~/Android

################
install Android NDK
################

Download Android NDK from https://developer.android.com/ndk/downloads/index.html#download
follow instruction to install it

create a symbolik link for later use

(CMD) ln -s /home/$HOME/Android/android-ndk-r10e /home/$HOME/Android/ndk

################
create symbolic link for linker
################

(CMD) cd /usr/bin
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-as arm-linux-as
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-ld arm-linux-ld

################
install Android Sdk
################
Download Android Sdk from https://developer.android.com/sdk/index.html#Other (SDK Tools Only)
and extract it

(CMD) tar xzvf android-sdk_r24.3.4-linux.tgz

create a symbolik link for later use

(CMD) ln -s /home/$HOME/Android/android-sdk-linux /home/$HOME/Android/sdk

################
install SDK packages
################
Follow these instructions
https://developer.android.com/sdk/installing/adding-packages.html

and install SDK packages
(CMD) ~/Android/sdk/tools/android sdk

################
modify your PATH
################
Add to your ~/.bashrc:
export PATH=$PATH:~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin

################
download FPC and LAZARUS
################

svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co http://svn.freepascal.org/svn/fpc/trunk fpc

################
install other needed packages
################
(ref.: http://wiki.freepascal.org/How_to_setup_a_FPC_and_Lazarus_Ubuntu_repository)
sudo apt-get install libgtk2.0-dev libgdk-pixbuf2.0-dev libgpm-dev fakeroot libncurses5-dev libtinfo-dev

################
BUILD FPC.DEB
################

(CMD) cd ~/Android/lazarus/tools/install
(CMD) ./create_fpc_deb.sh fpc /home/$HOME/Android/fpc/

################
purge fpc from system
################

REMOVE all fpc deb and fp_ deb (fpc, fpc-src, fp_compiler and so on)
(EX) sudo dpkg --remove fpc* fp-*

################
INSTALL the new trunk fpc package
################

(CMD) sudo dpkg -i ./fpc_3.1.1-150130_amd64.deb

################
BUILD FPC-SRC.DEB
we need source for fpc, now we create it, and install it
################

(CMD) ./create_fpc_deb.sh fpc-src /home/$HOME/Android/fpc/
(CMD) sudo dpkg -i fpc-src_3.1.1-150130_amd64.deb

################
BUILD LAZARUS.DEB AND INSTALL IT
################

(CMD) ./create_lazarus_deb.sh append-revision
(CMD) sudo dpkg -i lazarus_1.5.47565-0_amd64.deb

################
BUILD THE CROSS COMPILER
################

cd ~/Android/fpc
make clean crossall OS_TARGET=android CPU_TARGET=arm
sudo make crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr

################
create symbolic link for newly created arm compiler
################

(CMD) cd /usr/bin
(CMD) sudo ln -s /usr/lib/fpc/3.1.1/ppcrossarm .
(CMD) sudo ln -s /usr/bin/ppcrossarm ppcarm

################
update /etc/fpc.cfg
################
Add these lines to /etc/fpc.cfg

#IFDEF ANDROID
#IFDEF CPUARM
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
#ENDIF

################
install LAMW
################

(CMD) svn co https://github.com/jmpessoa/lazandroidmodulewizard.git
(CMD) ln -s /home/$HOME/Android/svn-lazandroidmodulewizard/trunk /home/$HOME/Android/lazandroidmodulewizard

################
Install LAMW on Lazarus
################

1. From Lazarus IDE - Install Wizard Packages
  1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk"  [Android Components Bridges!]
     1.1.1 From Package Wizard
                                - Compile
                                - Use -> Install
  1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
     1.2.1 From Package Wizard
                                - Compile
                                - Use -> Install
  1.3 Package -> Open Package -> "amw_ide_tools.lpk"  [folder: ..\LazAndroidWizard\ide_tools]
     1.3.1 From Package Wizard
                                - Compile
                                - Use -> Install

2. From Lazarus IDE menu Tools -->> "Android Module Wizard" --> Paths Settings"
  update paths settings according to your system
(ref. https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA1OF9yVVU3RA)

     -Path to Java JDK (ex. /usr/lib/jvm/java-7-openjdk-amd64)
     -Path to Android SDK( ex. /home/renabor/Android/sdk)
     -Path to Ant bin (ex. /usr/bin)
     -Select Ndk version: [10]
     -Path to Ndk (ex  /home/$HOME/Android/android-ndk-r10e)
     -Path to Java Resources  [Simonsayz's Controls.java,  *.xml and default Icons]: (ex. /home/$HOME/Android/svn-lazandroidmodulewizard/trunk/java)

################
BUILD YOUR FIRST PROJECT
################

Open a project from lazandroidmodulewizard/demos/Ant or lazandroidmodulewizard/demos/Eclipse directory
open ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1/jni/controls.lpi
from Project->Options, change/modify paths according to your system (under «paths» and «other»)

(ex. for «paths» ../../../Android/android-ndk-r10e/platforms/android-21/arch-arm/usr/lib;/home/$HOME/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/)

(ex. for «other» -Xd -CfSoft -CpARMV6 -XParm-linux-androideabi- -FD/home/$HOME/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin)

build it!

################
################
compile for ARM
################
################

from shell
(CMD) cd ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1

################
build.xml
################

<?xml version="1.0" encoding="UTF-8"?>
<project name="AppDemo1" default="help">
<property name="sdk.dir" location="/home/$HOME/Android/sdk"/>
<property name="target"  value="android-19"/>
<property file="ant.properties"/>
<fail message="sdk.dir is missing." unless="sdk.dir"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>

################
build.sh
################

edit build.sh leaving only this line:

   ant -Dtouchtest.enabled=true debug

################
install.sh
################

remove content of install.sh and replace it with:

/home/$HOME/Android/sdk/platform-tools/adb uninstall com.example.appdemo1
/home/$HOME/Android/sdk/platform-tools/adb install -r bin/AppDemo1-debug.apk
/home/$HOME/Android/sdk/platform-tools/adb logcat

################
Connect a device
################

run an emulator
(CMD) ~/Android/sdk/tools/android avd &

################
COMPILE AND INSTALL
################

(CMD) chmod +x ./build.sh && chmod +x ./install.sh
(CMD) ./build.sh
(CMD) ./install.sh

Enjoy!
Title: Re: Android Module Wizard
Post by: xinyiman on August 27, 2015, 01:25:21 pm
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
Title: Re: Android Module Wizard
Post by: euller on August 27, 2015, 06:38:36 pm
I've discovered the problem. but still didn't find a solution.
Here is the deal, when I call jHttpClient.OnContentResult, I receive a string named content right? Well, I use this string to fill a JSON array, and use that array to fill a ListView, and boom, crashes. Right now I'm digging up the reason, I will tell when more information is available.
Title: Re: Android Module Wizard
Post by: euller on August 27, 2015, 09:28:11 pm
New info, doesn't matter where the code is, it simply doesn't work, here, a sample of how it looks:

Code: [Select]
procedure TMiniActivity.PopulateList(content: String);
var
  vja: TJSONArray = nil;
  i: Integer;
  s: String;
begin
  if Trim(content) <> '' then
  begin
    try
      s:='';
      vja:= TJSONArray(GetJSON(content));
      for i:=0 to vja.Count-1 do
      begin
        s:= vja.Objects[i].Strings['data_a']+' - '+vja.Objects[i].Strings['data_2'];
        jListView1.Add(s);
      end;
    except
      ShowMessage('Operation error');
    end;
    FreeAndNil(vja);
  end;
end;

I've done this code over and over for desktop and web applications, but in android with LAMW it doesn't work. I'm starting to suspect that is something I'm totally oblivious going on and I've ran out of ideas of how to find it. Does someone has any thoughts?
Title: Re: Android Module Wizard
Post by: jmpessoa on August 28, 2015, 12:02:28 am
@Euller,

I Think your problem in " JSON" cross-compile support...  In my sytem I have:

"C:\laz4android\fpc\x.y.z\units\arm-android\fcl-json"

and you ?
Title: Re: Android Module Wizard
Post by: Leledumbo on August 28, 2015, 09:00:32 am
New info, doesn't matter where the code is, it simply doesn't work, here, a sample of how it looks:

Code: [Select]
procedure TMiniActivity.PopulateList(content: String);
var
  vja: TJSONArray = nil;
  i: Integer;
  s: String;
begin
  if Trim(content) <> '' then
  begin
    try
      s:='';
      vja:= TJSONArray(GetJSON(content));
      for i:=0 to vja.Count-1 do
      begin
        s:= vja.Objects[i].Strings['data_a']+' - '+vja.Objects[i].Strings['data_2'];
        jListView1.Add(s);
      end;
    except
      ShowMessage('Operation error');
    end;
    FreeAndNil(vja);
  end;
end;

I've done this code over and over for desktop and web applications, but in android with LAMW it doesn't work. I'm starting to suspect that is something I'm totally oblivious going on and I've ran out of ideas of how to find it. Does someone has any thoughts?
At least 2:
Title: Re: Android Module Wizard
Post by: euller on August 28, 2015, 01:09:23 pm
@Euller,

I Think your problem in " JSON" cross-compile support...  In my sytem I have:

"C:\laz4android\fpc\x.y.z\units\arm-android\fcl-json"

and you ?

yes, I do

At least 2:
  • Make a good use of the raised exception object, try-except can explain more precisely what happens
  • ShowMessage the content before passing it to GetJSON, make sure it really is a valid JSON

I've done that, this code was to simply show the situation
Title: Re: Android Module Wizard
Post by: renabor on August 28, 2015, 07:03:43 pm
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
Thank you! I'm trying install LAMW in a fresh lubuntu virtual machine too, but I have problems in preparing lazarus deb package, the error is:

(9022) Compiling resource ../units/i386-linux/gtk2/lazarus.or
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Error: (9030) Can't call the resource compiler "/usr/bin/fpcres", switching to external mode
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crti.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crtn.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Fatal: (10026) There were 1 errors compiling module, stopping

revisions of fpc and lazarus are retrieved with:

svn co -r 49563 http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co -r 31226 http://svn.freepascal.org/svn/fpc/trunk fpc

/usr/bin/fpcres is still present in my system, but not used, why?!?
Have you had better result?


Title: Re: Android Module Wizard
Post by: xinyiman on August 28, 2015, 08:55:03 pm
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
Thank you! I'm trying install LAMW in a fresh lubuntu virtual machine too, but I have problems in preparing lazarus deb package, the error is:

(9022) Compiling resource ../units/i386-linux/gtk2/lazarus.or
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Error: (9030) Can't call the resource compiler "/usr/bin/fpcres", switching to external mode
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crti.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crtn.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Fatal: (10026) There were 1 errors compiling module, stopping

revisions of fpc and lazarus are retrieved with:

svn co -r 49563 http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co -r 31226 http://svn.freepascal.org/svn/fpc/trunk fpc

/usr/bin/fpcres is still present in my system, but not used, why?!?
Have you had better result?

Hello , I went addition , the preparation of the deb package of Lazarus had no problems . I have no problem about this command because you did not specify from which folder I launch

make clean crossall OS_TARGET=android CPU_TARGET=arm

~/Android/fpc?!
Title: Re: Android Module Wizard
Post by: xinyiman on August 28, 2015, 11:00:06 pm
When install tfpandroidbridge_pack.lpk
Why?!

Costruisci la IDE: Codice di uscita 512, Errori: 1, avvertimenti: 2
lazarus.pp(144,1) Warning: "crti.o" not found, this will probably cause a linking failure
lazarus.pp(144,1) Warning: "crtn.o" not found, this will probably cause a linking failure
/usr/bin/ld: warning: ../link.res contains output sections; did you forget -T?

/usr/bin/ld: cannot find -lGL
lazarus.pp(144,1) Error: Error while linking
Title: Re: Android Module Wizard
Post by: euller on August 29, 2015, 04:33:02 pm
Hey guys, here is what I think is the reason of my problem:

http://stackoverflow.com/questions/14495242/android-fatal-signal-11-sigsegv-at-0x00000040-code-1-error (http://stackoverflow.com/questions/14495242/android-fatal-signal-11-sigsegv-at-0x00000040-code-1-error)

If you look at the answer instead of the question as I did, you may came to the same conclusion I had: the two problems have the same reason, but I could be wrong. So please help me to find an answer.
Title: Re: Android Module Wizard
Post by: Leledumbo on August 29, 2015, 05:39:44 pm
/usr/bin/ld: cannot find -lGL
libGL is part of your OpenGL capable graphics card driver. You need to install the respective development package.
Title: Re: Android Module Wizard
Post by: renabor on August 29, 2015, 05:47:18 pm
Hey guys, here is what I think is the reason of my problem:

http://stackoverflow.com/questions/14495242/android-fatal-signal-11-sigsegv-at-0x00000040-code-1-error (http://stackoverflow.com/questions/14495242/android-fatal-signal-11-sigsegv-at-0x00000040-code-1-error)

If you look at the answer instead of the question as I did, you may came to the same conclusion I had: the two problems have the same reason, but I could be wrong. So please help me to find an answer.

All error 11-sigsev related with my code was caused by accessing empty array or using a cursor after a malformed sql query.
Are you sure that Strings['data_a'] and Strings['data_2'] are valid and reachable?

s:= vja.Objects.Strings['data_a']+' - '+vja.Objects.Strings['data_2'];

Try to use variable as arry index instead of string

Code: [Select]
const DATA_A = 'data_a';
DATA_2 = 'data2';
s:= vja.Objects[i].Strings[DATA_A]+' - '+vja.Objects[i].Strings[DATA_2];

for me was a solution many times
Title: Re: Android Module Wizard
Post by: renabor on August 29, 2015, 06:43:00 pm
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
Thank you! I'm trying install LAMW in a fresh lubuntu virtual machine too, but I have problems in preparing lazarus deb package, the error is:

(9022) Compiling resource ../units/i386-linux/gtk2/lazarus.or
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Error: (9030) Can't call the resource compiler "/usr/bin/fpcres", switching to external mode
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crti.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crtn.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Fatal: (10026) There were 1 errors compiling module, stopping

revisions of fpc and lazarus are retrieved with:

svn co -r 49563 http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co -r 31226 http://svn.freepascal.org/svn/fpc/trunk fpc

/usr/bin/fpcres is still present in my system, but not used, why?!?
Have you had better result?

Hello , I went addition , the preparation of the deb package of Lazarus had no problems . I have no problem about this command because you did not specify from which folder I launch

make clean crossall OS_TARGET=android CPU_TARGET=arm

~/Android/fpc?!

Yes, you execute the command from ~/Android/fpc

but just before you MUST create following symlinks:

Code: [Select]
(CMD) cd /usr/bin
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-as arm-linux-as
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-ld arm-linux-ld

N.B. if you use reference to 4.8 here, you must ensure to use reference to 4.8 everywhere when configuring LAMW
Title: Re: Android Module Wizard
Post by: xinyiman on August 29, 2015, 06:51:55 pm
/usr/bin/ld: cannot find -lGL
libGL is part of your OpenGL capable graphics card driver. You need to install the respective development package.
Thank you :)
Title: Re: Android Module Wizard
Post by: xinyiman on August 29, 2015, 06:56:02 pm
I installed all of a VM Lubuntu . Now I have a problem in compiling the demo , it gives me these errors . Why?!

Code: [Select]
.
.
.
Compila il progetto, OS: android, CPU: arm, Destinazione: /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/libs/armeabi/libcontrols.so.so: Codice di uscita 256, Errori: 4, suggerimenti: 3
unit1.pas(9,22) Hint: Unit "And_jni" not used in unit1
unit1.pas(9,31) Hint: Unit "And_jni_Bridge" not used in unit1
unit1.pas(10,5) Hint: Unit "Laz_And_Controls_Events" not used in unit1
controls.lpr(335,3) Error: Identifier not found "Java_Event_pOnBluetoothClientSocketIncomingMessage"
controls.lpr(343,3) Error: Identifier not found "Java_Event_pOnBluetoothClientSocketWritingMessage"
controls.lpr(359,3) Error: Identifier not found "Java_Event_pOnBluetoothServerSocketIncomingMessage"
controls.lpr(367,3) Error: Identifier not found "Java_Event_pOnBluetoothServerSocketWritingMessage"
Title: Re: Android Module Wizard
Post by: jmpessoa on August 29, 2015, 07:06:09 pm
@xinyiman

from "readme.txt":

special note:
Quote
   *5.PANIC ? [upgrade your project [or demo] code templates!] !
   *   Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]


Quote
   *How to use [projects] demos :
   *
   *1. Open the lazarus project "controls.lpi" [...\jni]
   *
   *   Lazarus IDE menu:  "Project" --> "View Project Source"
   *   Lazarus IDE menu:  "Project" --> "Forms...."
   *
   *2. Change this informations in "controls.lpi" to correct one!
   *
   *   "C:\adt32\ndk10"   -- just my system NDK path
   *
   *3. Change this informations in  "build.xml"   according your system..
   *   "C:\adt32\sdk"
   *         
   *   Option 1: NEW !!
   *      .IDE --> Tools -->
   *            [Lamw] Android Module Wizard -->
   *               Change Project [*.lpi] Ndk Path [Demos]
   *      .Change/edit "build.xml": "C:\adt32\sdk" according your system..
   *
   *   Option 2: Go to Lazarus IDE:
   *         ->Project
   *         ->Project -> Option
   *         ->Path -->> change/modify paths according to your system ..
   *
   *   Option 3: Open/edit the "controls.lpi" [...\jni] and "build.xml". You can use Notepad like editor....
   *         
   *
   *4. All [compatible] Eclipse projects support Ant!
   *         You can build/install/Run all Eclipse projects just with "Ant"...
   *         see "build.bat" [or .sh] and "install.bat" or [.sh]
   *         or Go To: Lazarus IDE menu "Run--> [Lamw] Build and Run"! Thanks to Anton!!!
   *
   *5.PANIC ? [upgrade your project [or demo] code templates!] !
   *   Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]
   *
   *6.PANIC ? When prompt "Read error" [Unknown Property] just choice "Continue Loading" !
   *
   *7.PANIC ? Fail to build Apk. Change according your system installation:
   *
   *   "AndroidManifest.xml"       
   *      <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17"/>
   *
   *   "build.xml"   
   *      <property name="target"  value="android-17"/>
   *
   *   "build.xml"
   *      <property name="sdk.dir" location="C:\adt32\sdk"/>
   *

But, what about your first "hello world!" apk? all right?
Title: Re: Android Module Wizard
Post by: renabor on August 29, 2015, 07:09:23 pm
I installed all of a VM Lubuntu . Now I have a problem in compiling the demo , it gives me these errors . Why?!

Code: [Select]
.
.
.
Compila il progetto, OS: android, CPU: arm, Destinazione: /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/libs/armeabi/libcontrols.so.so: Codice di uscita 256, Errori: 4, suggerimenti: 3
unit1.pas(9,22) Hint: Unit "And_jni" not used in unit1
unit1.pas(9,31) Hint: Unit "And_jni_Bridge" not used in unit1
unit1.pas(10,5) Hint: Unit "Laz_And_Controls_Events" not used in unit1
controls.lpr(335,3) Error: Identifier not found "Java_Event_pOnBluetoothClientSocketIncomingMessage"
controls.lpr(343,3) Error: Identifier not found "Java_Event_pOnBluetoothClientSocketWritingMessage"
controls.lpr(359,3) Error: Identifier not found "Java_Event_pOnBluetoothServerSocketIncomingMessage"
controls.lpr(367,3) Error: Identifier not found "Java_Event_pOnBluetoothServerSocketWritingMessage"

Try upgrading code template:

From menu Tools->[Lamw]->Upgrade Code Templates
Title: Re: Android Module Wizard
Post by: xinyiman on August 29, 2015, 10:10:37 pm
Thankk you. But now when run sh build.sh

Code: [Select]
Buildfile: /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.3.4
 [checkenv] Installed at /home/generico/Android/sdk

-setup:
     [echo] Project Name: AppAntDemo1
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.0
     [echo] Resolving Build Target for AppAntDemo1...
[gettarget] Project Target:   Android 6.0
[gettarget] API level:        23
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/bin/rsObj
    [mkdir] Created dir: /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/bin/rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for AppAntDemo1...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] No changed resources. R.java and Manifest.java untouched.
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 4 source files to /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/bin/classes
    [javac] /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/src/org/lazarus/appantdemo1/Controls.java:280: error: package org.apache.http does not exist
    [javac] import org.apache.http.HttpEntity;
    [javac]                       ^
    [javac] /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/src/org/lazarus/appantdemo1/Controls.java:281: error: package org.apache.http does not exist
    [javac] import org.apache.http.HttpResponse;
    [javac]                       ^
    [javac] /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/src/org/lazarus/appantdemo1/Controls.java:282: error: package org.apache.http does not exist
    [javac] import org.apache.http.NameValuePair;
    [javac]                       ^
    [javac] /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/src/org/lazarus/appantdemo1/Controls.java:283: error: package org.apache.http does not exist
    [javac] import org.apache.http.StatusLine;
    [javac]                       ^
    [javac] /home/generico/Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1/src/org/lazarus/appantdemo1/Controls.java:284: error: package org.apache.http.auth does not exist
    [javac] import org.apache.http.auth.AuthScope;
    [javac]                            ^

and other similar error
Title: Re: Android Module Wizard
Post by: jmpessoa on August 29, 2015, 10:59:05 pm
@xinyiman

Quote
...package org.apache.http.auth does not exist

I think you have some problem with the java [configuration] path ... 
Title: Re: Android Module Wizard
Post by: xinyiman on August 30, 2015, 10:44:29 am
@xinyiman

Quote
...package org.apache.http.auth does not exist

I think you have some problem with the java [configuration] path ...
View attachment
Title: Re: Android Module Wizard
Post by: renabor on August 30, 2015, 03:47:06 pm
@xinyiman

Quote
...package org.apache.http.auth does not exist

I think you have some problem with the java [configuration] path ...
View attachment

Error is clear:

«package org.apache.http does not exist»

compiler can't find it.

have you adapted build.xml to your system?
have you downloaded the necessary sdk library for your target?
Title: Re: Android Module Wizard
Post by: xinyiman on August 30, 2015, 10:15:03 pm
my build.xml
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<project name="AppAntDemo1" default="help">
  <property name="sdk.dir" location="/home/generico/Android/sdk"/>
  <property name="target" value="android-23"/>
  <property file="ant.properties"/>
  <fail message="sdk.dir is missing." unless="sdk.dir"/>
  <import file="${sdk.dir}/tools/ant/build.xml"/>
</project>

my AndroidManifest.xml
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.lazarus.appantdemo1" android:versionCode="1" android:versionName="1.0">
  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  <uses-permission android:name="android.permission.BLUETOOTH"/>
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
  <uses-permission android:name="android.permission.CAMERA"/>
  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.READ_CONTACTS"/>
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  <uses-permission android:name="android.permission.READ_OWNER_DATA"/>
  <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
  <uses-permission android:name="android.permission.SEND_SMS"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <uses-permission android:name="android.permission.WRITE_OWNER_DATA"/>
  <uses-feature android:name="android.hardware.camera" android:required="false"/>
  <uses-feature android:name="android.hardware.camera.flash" android:required="false"/>
  <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
  <uses-feature android:name="android.hardware.telephony" android:required="false"/>
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true"/>
  <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
    <activity android:name="org.lazarus.appantdemo1.App" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize|screenLayout|fontScale">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
  </application>
</manifest>

View attachment for build log
Title: Re: Android Module Wizard
Post by: jmpessoa on August 30, 2015, 10:28:31 pm
@xinyiman

what about your first "hello world!" apk? all right?

there is a "readme_get_start.txt" to help ....
Title: Re: Android Module Wizard
Post by: xinyiman on August 30, 2015, 11:20:26 pm
Installed API 23 for sdk is this the problem?!
Title: Re: Android Module Wizard
Post by: jmpessoa on August 31, 2015, 12:20:36 am
@xinyiman

Quote
...Installed API 23 for sdk is this the problem?!

You can try other  API .... I do not test API 23 ... 
[but if API 23 dropped  apache HttpClient, we have a problem!]
Title: Re: Android Module Wizard
Post by: renabor on August 31, 2015, 06:38:24 am
@xinyiman

Quote
...Installed API 23 for sdk is this the problem?!

You can try other  API .... I do not test API 23 ... 
[but if API 23 dropped  apache HttpClient, we have a problem!]

You are on the right path jmpessoa, org.apache.http.client was removed in API 23. It is better, xinyiman, that you target your app to API 21, just to avoid such problems

http://developer.android.com/sdk/api_diff/23/changes.html

Title: Re: Android Module Wizard
Post by: xinyiman on August 31, 2015, 12:59:44 pm
With 21 API are able to compile correctly.
How do I configure the emulator Android?
So then release the virtual machine.
Title: Re: Android Module Wizard
Post by: euller on August 31, 2015, 02:09:51 pm
All error 11-sigsev related with my code was caused by accessing empty array or using a cursor after a malformed sql query.
Are you sure that Strings['data_a'] and Strings['data_2'] are valid and reachable?

Yes, before calling the method I've assured that I had something to retrieve, it's just to simple act of trying to retrieve, that fires the error.
Title: Re: Android Module Wizard
Post by: renabor on August 31, 2015, 02:43:51 pm
With 21 API are able to compile correctly.
How do I configure the emulator Android?
So then release the virtual machine.

~/Android/sdk/tools/android avd &

Title: Re: Android Module Wizard
Post by: renabor on August 31, 2015, 02:44:58 pm
All error 11-sigsev related with my code was caused by accessing empty array or using a cursor after a malformed sql query.
Are you sure that Strings['data_a'] and Strings['data_2'] are valid and reachable?

Yes, before calling the method I've assured that I had something to retrieve, it's just to simple act of trying to retrieve, that fires the error.

Other solution that I gived you worked?
Title: Re: Android Module Wizard
Post by: euller on August 31, 2015, 03:01:31 pm
@renabor:

Nope, not even changed the output.
Title: Re: Android Module Wizard
Post by: xinyiman on August 31, 2015, 06:17:51 pm
With 21 API are able to compile correctly.
How do I configure the emulator Android?
So then release the virtual machine.

~/Android/sdk/tools/android avd &

How set this in LAMW?!
Title: Re: Android Module Wizard
Post by: euller on August 31, 2015, 09:07:06 pm
for anyone who cares, I've created a topic to discuss my problem, because I feel that I'm sidetracking this topic with my situation, please contribute with it
Title: Re: Android Module Wizard
Post by: xinyiman on September 01, 2015, 07:26:57 am
Hello curiosity , how come when I click twice on a component in place to create me the event editor gives me this error ?

Title: Re: Android Module Wizard
Post by: xinyiman on September 02, 2015, 11:32:27 am
Solved, it was enough to re-read him the source directory of free pascal.
One more question, to find an example of the use of tested and working database where do I go?
Title: Re: FYI. don't set API = 23 until fixing the text relocations
Post by: simonsayz on September 12, 2015, 05:07:56 pm
Always Thanks.

Just Tip for using Android Module Wizard

Maybe, Android 6.0 policy will be changed.

Android 6.0 (API =23) can't loading App when has Text Relocations.
Until today, FPC generate shared library with RextREL,
So, When set API =23, App will be crashed.

Ref. http://slowbutdeadly.blogspot.kr/2015/09/javalangunsatisfiedlinkerror-dlopen.html


## Updated Information (09.18.2015) ##
svn r31739 : FPC supports the PIC
Now, FPC app works on Android 6.o (targetSDK = 23)
Thanks to Yury Sidorov


Best Regards
Simon,Choi

Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on September 19, 2015, 11:12:28 am
hi all
I find in list of max target api ( menu create new project ) a list from 15 to 21
but from 22, I dont find, have lamw not support higher api yet ?
Title: Re: Android Module Wizard
Post by: xinyiman on September 19, 2015, 01:12:09 pm
Hello guys, some advice, I have to create a program that allows the inclusion of data with a component similar to a grid. Is there anything like that?

Also as a component should I use to use the tab?
Title: Re: Android Module Wizard
Post by: jmpessoa on September 19, 2015, 07:22:18 pm
@m4u_hoahoctro

Yes, we have some problems  with API = 23

1. jHttpClient fail!

 solution:  redesign jHttpClient code is need ....

2. FPC fail!

solution by simonsayz:

http://forum.lazarus.freepascal.org/index.php/topic,29713.0.html

@TrueTom,   

what a about a new "Laz4Android"  with FPC simonsayz patch?


@xinyiman,

There are:

 "jGridView" component and "AppGridViewDemo1"


"jActionBar" component  and "AppActionBarTabDemo1"

Please,  Upgrade demos code:

Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

More info about "demos" use: "readme.txt"

Thanks to All!!!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on September 20, 2015, 10:52:55 am
@m4u_hoahoctro

Yes, we have some problems  with API = 23

1. jHttpClient fail!

 solution:  redesign jHttpClient code is need ....

2. FPC fail!

solution by simonsayz:

http://forum.lazarus.freepascal.org/index.php/topic,29713.0.html


So it means my app ( including component jhttpclient) will cant run on android M ?  :o
Title: Re: Android Module Wizard
Post by: jmpessoa on September 20, 2015, 04:31:09 pm
@m4u_hoahoctro,

Yes, but you can run it [on "M"] just now!

What you can not do is compile with [sdk] API=23 or target API=23 ...

[NOTE: I don't have an "API 23" real device .. so, I have not done any test ...]

As soon as possible I will redesign/recode "jHttpClient" ... [in fact these days I have been very very busy... sorry ...]

by simonsayz:
Quote
## Updated Information (09.18.2015) ##
svn r31739 : FPC supports the PIC
Now, FPC app works on Android 6.o (targetSDK = 23)
Thanks to Yury Sidorov
Title: Re: Android Module Wizard
Post by: euller on September 23, 2015, 09:52:08 pm
guys, is there any component, besides the sqlite one, that stores information of the application, even if the device shut down?
Title: Re: Android Module Wizard
Post by: jmpessoa on September 24, 2015, 07:31:57 pm

Hello Euller!

You can try "jPreferences" component to store/read "key=value" pair!


    function GetIntData(_key: string; _defaultValue: integer): integer;
    procedure SetIntData(_key: string; _value: integer);

    function GetStringData(_key: string; _defaultValue: string): string;
    procedure SetStringData(_key: string; _value: string);

    function GetBoolData(_key: string; _defaultValue: boolean): boolean;
    procedure SetBoolData(_key: string; _value: boolean);

About:
Quote
..that stores information of the application, even if the device shut down..

Yes!
Title: Re: Android Module Wizard
Post by: xinyiman on September 24, 2015, 10:10:29 pm
Hi, one question. Why this error into new project?

Messaggi, suggerimenti: 2
Note: Duplicate unit "controls" in "controls", orphaned ppu "/home/generico/Android/LamwProjects/Test1/obj/controls/controls.o"
Note: Duplicate unit "controls" in "LCLBase 1.5", ppu="/usr/share/lazarus/1.5.49718/lcl/units/arm-android/controls.ppu", source="/usr/share/lazarus/1.5.49718/lcl/controls.pp"
Compila il progetto, OS: android, CPU: arm, Destinazione: /home/generico/Android/LamwProjects/Test1/libs/armeabi/libcontrols.so: Codice di uscita 256, Errori: 1, suggerimenti: 2
controls.lpr(1223,34) Hint: Parameter "reserved" not used
controls.lpr(1239,37) Hint: Parameter "reserved" not used
controls.lpr(1427,15) Error: Util arm-linux-androideabi-ld not found, switching to external linking

Title: Re: Android Module Wizard
Post by: jmpessoa on September 24, 2015, 10:59:55 pm

Hello xinyiman!

Ok,  duplicate unit "controls" is bad, but not an "error" [you got just a "note"] ... sorry.


Your "error" is here:

Quote
controls.lpr(1427,15) Error: Util arm-linux-androideabi-ld not found ...

Possibly your cross-compile [config] system is incomplete/incorrect ...

Title: Re: Android Module Wizard
Post by: renabor on September 25, 2015, 01:03:40 pm
Hello xinyiman!

As said by jmpessoa, the error is related to

Code: [Select]
arm-linux-androideabi-ld not found

to resolve you can add proper dir in $PATH or make symbolic link to both ld and as, this way:

################
create symbolic link for linker
################

(CMD) cd /usr/bin
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as arm-linux-androideabi-as
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd arm-linux-androideabi-ld
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-as arm-linux-as
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-ld arm-linux-ld

change arm-linux-androideabi-4.8 to arm-linux-androideabi-4.6 if you are using it in config-properties of your project

Title: Re: Android Module Wizard
Post by: xinyiman on September 25, 2015, 03:15:01 pm
Is impossibile, because when i compiled the ant demo it's all ok!

Hello xinyiman!

As said by jmpessoa, the error is related to

Code: [Select]
arm-linux-androideabi-ld not found

to resolve you can add proper dir in $PATH or make symbolic link to both ld and as, this way:

################
create symbolic link for linker
################

(CMD) cd /usr/bin
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as arm-linux-androideabi-as
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd arm-linux-androideabi-ld
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-as arm-linux-as
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-ld arm-linux-ld

change arm-linux-androideabi-4.8 to arm-linux-androideabi-4.6 if you are using it in config-properties of your project
Title: Re: Android Module Wizard
Post by: renabor on September 25, 2015, 03:21:52 pm
Hello xinyiman!
can you run this command in a shell and post the result?

which arm-linux-androideabi-ld

Title: Re: Android Module Wizard
Post by: xinyiman on September 25, 2015, 03:34:34 pm
/home/generico/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
Title: Re: Android Module Wizard
Post by: renabor on September 25, 2015, 04:02:48 pm
/home/generico/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-ld

Are you able to compile with 4.9? After some attempts and many errors I revert to 4.8.
In Project->Project Option have you all paths sets according to your choice of using 4.9?
There are 2 points to control: Paths and Others
Title: Re: Android Module Wizard
Post by: xinyiman on September 25, 2015, 04:08:22 pm
Is in "other" the problem, thank you very much

 ;D
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on September 27, 2015, 12:02:26 pm
Hi jmpessoa
I tried this code for my app, but when I type true info of account, app auto closes and I dont know why  :o

Code: [Select]
procedure TAndroidModule1.jAsyncTask1PostExecute(Sender: TObject;
  progress: integer);
begin
 if actiontype=1 then
 begin
 jedittext2.clear;
 if content1='user info not match' then jedittext1.text:='please try again'
 else
  begin
  if androidmodule2=nil then
  begin
    gapp.CreateForm(tandroidmodule2,androidmodule2);
    androidmodule2.Init(gapp);
  end;
  androidmodule2.Show;
  androidmodule1.finish;
  end;
end;

 if actiontype=2 then
 begin
 jedittext3.clear;
 jedittext4.clear;
 jedittext5.clear;
 if content1='your account have been created' then jedittext3.text:='Done, press back button to login'
 else jedittext3.text:='there was some errors, please try again';
 end;

 jasynctask1.Done;
 froyo.Stop;
end;                   


php code ( on server )
Code: [Select]
<?php
$conn
=mysqli_connect("mysql.hostinger.vn","I hided user and password of hosting","","");
mysqli_select_db($conn,"I hided this info");
$login=false;
if (empty(
$_GET['login'])==false)
{
    
    
$querycommand="Select * from account";
    
$excutequery=mysqli_query($conn,$querycommand);
    while (
$rows=mysqli_fetch_assoc($excutequery))
    {
        if ((
$_GET['user']==$rows[user]) and ($_GET['password']==$rows['password']))
        {
            
$login=true;
            break;
        }
    }
    if (
$login==false
    {
        echo 
'user info not match';
    }
    else
    {
        echo 
'user info matches';
    }

}

if (empty(
$_GET['register'])==false)
{
    
$user=$_GET['user'];
    
$password=$_GET['password'];
    
$numberphone=$_GET['phone'];
    
$querycommand="Insert into account (user,password,numberphone) values('$user','$password','$numberphone') ";
    
$excutequery=mysqli_query($conn,$querycommand);
    if (
$excutequery==true)
    {
        echo 
"your account have been created";
    }
    else
    {
        echo 
"there was some error";
    }
}




?>
Title: Re: Android Module Wizard
Post by: xinyiman on September 27, 2015, 08:01:28 pm
Hello, I wanted to ask you something, I used a grid to see the data, but if I want to change the content of the grid cells, what is the most comfortable for the user? There is the possibility to change his content directly from the grid?
Title: Re: Android Module Wizard
Post by: renabor on September 30, 2015, 05:33:31 pm
Hello, I wanted to ask you something, I used a grid to see the data, but if I want to change the content of the grid cells, what is the most comfortable for the user? There is the possibility to change his content directly from the grid?

Hello @xinyiman!

I'm sorry but I never used jGridView1, but you can install the app AppGridViewDemo1/bin/AppGridViewDemo1.apk and then give a look at the source  AppGridViewDemo1.
For further inspiration take a look into unit gridview.pas, where class jGridView is defined
Title: Re: Android Module Wizard
Post by: xinyiman on September 30, 2015, 06:13:11 pm
I tried to look, but the example only shows how to add fields in the grid. For example, it does not explain how to change them. Why pensado add a editbox by which to modify the data of the selected cell.
Title: Re: Android Module Wizard
Post by: Sait™ on October 06, 2015, 06:17:54 am
Hi jmpessoa. Thanks for your hard work.
But i'm having a problem. When i create new project with JNI (Lamw GUI), it response a error message only: "List index (-1) out of bounds".
All version installed is newest: laz4a 1.5 49903 and lamw which i have just downloaded 2 hour ago.
Title: Re: Android Module Wizard
Post by: DonAlfredo on October 06, 2015, 04:16:19 pm
@jmpessoa
First, thanks for a very nice tool !
However, I am encountering a strange problem.

E.g.
I have a datamodule (form) with two ImageViews.
App runs fine.
I add a third ImageView.
App crashes on startup.
I add a fourth ImageView and delete the third ImageView.
App runs fine.

Can you help ?
Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 06, 2015, 04:52:21 pm

Hello Sait!

Hello DonAlfredo!

I'll try to understand what's going on .. and fix it!

Thanks!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 07, 2015, 08:55:42 am

Hello  Sait! Hello All!

I just  downloaded [today] lamw  from "github" and yes, it was not working... sorry

But now [after some fixs], I think it is Ok!

Thanks to All!
Title: Re: Android Module Wizard
Post by: DonAlfredo on October 07, 2015, 11:27:28 am
Thanks !
Works much better (100%) with the new version !!
(drawback: I had to recreate the whole project to get the positive effects)

Few questions remain:

1)
I have a jTextView on my form.
I set text property to empty string (delete contents)
I set hint to display some text on empty showup.
Works well.
Close project.
Open project
Text property is filled again.
E.g.: I have to delete the text property by hand everytime I open the project !

2)
I have a jTextView inside a jPanel.
Setting the vertical size to matchparent (jPanel) causes some strange effects when dragging or editing the jPanel and/or the jTextView.

3)
I have made a simple demo project (copy of Sample 1) using the mORMot (http://synopse.info)
Would you like to include it into the LAMW samples ?
Title: Re: Android Module Wizard
Post by: Sait™ on October 07, 2015, 12:29:16 pm
@jmpessoa Glad to hear it. I'm downloading now :D . Thanks so much
Title: Re: Android Module Wizard
Post by: jmpessoa on October 08, 2015, 12:05:28 am


Hello DonAlfredo!


Ok  I will try improve/fix  [1] and [2]

Quote
3) I have made a simple demo project (copy of Sample 1) using the mORMot (http://synopse.info) Would you like to include it into the LAMW samples ?

Yes!  Thank you!  (I send a "PM" to you)
Title: Re: Android Module Wizard
Post by: jmpessoa on October 08, 2015, 01:37:37 am
Hello xinyiman!
 
Updated: https://github.com/jmpessoa/lazandroidmodulewizard

"jGridView" now can change Item title!

Code: Pascal  [Select][+][-]
  1.    procedure UpdateItemTitle(_index: integer; _title: string);
  2.  

You can get  "index" handling "onclick" event ....

Thank you!
Title: Re: Android Module Wizard
Post by: xinyiman on October 08, 2015, 08:18:33 am
Hello xinyiman!
 
Updated: https://github.com/jmpessoa/lazandroidmodulewizard

"jGridView" now can change Item title!

Code: Pascal  [Select][+][-]
  1.    procedure UpdateItemTitle(_index: integer; _title: string);
  2.  

Thank you very much  :D

You can get  "index" handling "onclick" event ....

Thank you!
Title: Re: Android Module Wizard
Post by: xinyiman on October 08, 2015, 10:55:18 pm
I installed the new version of Blades, compiles correctly, but when I open my old project instead of me see the graphics properly only shows the icons of the individual components on the form. Why?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 09, 2015, 12:49:25 am

Hello xinyiman [and All!]

If  you updated  your "Lamw" then after OPEN a "old" project you need upgrade your
code templates!

Lazarus IDE --> Tools --> Lamw [Android Module Wizard] --> Upgrade Code Templates [...]


Quote
I installed the new version of Blade ... %)

Please, put a figure/image here....
Title: Re: Android Module Wizard
Post by: Sait™ on October 09, 2015, 03:49:57 pm
Hi jmpessoa. Please fix jswitchbutton component. ex:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jSwitchButton1Toggle(Sender: TObject; state: boolean);
  2. begin
  3.   if jSwitchButton1.State=tsOn then ShowMessage('On')
  4.   else if jSwitchButton1.State=tsOff then ShowMessage('Off');
  5. end;
When I toggle the switch button, the property Sate 's value is always tsOff, so the message is always 'Off' too.
Title: Re: Android Module Wizard
Post by: xinyiman on October 09, 2015, 05:52:59 pm

Hello xinyiman [and All!]

If  you updated  your "Lamw" then after OPEN a "old" project you need upgrade your
code templates!

Lazarus IDE --> Tools --> Lamw [Android Module Wizard] --> Upgrade Code Templates [...]


Quote
I installed the new version of Blade ... %)

Please, put a figure/image here....

View attachment
Title: Re: Android Module Wizard
Post by: jmpessoa on October 10, 2015, 05:09:51 am
@Sait

Quote
..Please fix jswitchbutton component

Fixed!

Thank you!

@xinyiman

I could not understand what may be happening to your system...  sorry.


NEW!!   [By @DonAlfredo]

Demo project using the mORMot framework (http://synopse.info)  included into the LAMW samples!

Note: LAMW "AppmORMotDemo1-debug.apk"   just 2241 KB !

Thank you very much!
Title: Re: Android Module Wizard
Post by: xinyiman on October 10, 2015, 08:38:00 am
I uninstalled and reinstalled it all works now.
Title: Re: Android Module Wizard
Post by: xinyiman on October 10, 2015, 07:40:49 pm
One question , I have not yet figured out how to change the version number of my application . I thought he did on automatically each compilation , but I do not think so . Because when I go to install the apk file on my Android device did not update the version . Why? Who tells me how to do?
Title: Re: Android Module Wizard
Post by: xinyiman on October 10, 2015, 11:04:48 pm
Other question. How view a static image into my project?
Project name is jni/img/logo.png

Thank you
Title: Re: Android Module Wizard
Post by: jmpessoa on October 11, 2015, 05:57:25 am
Hello  xinyiman!

I have not yet figured out how to change the version number... too, sorry.  :-[

About Image:

1. Put your image into folders "..\res\drawable-xhdpi"  etc.... example: "ic_launcher.png"

then [in design time .... or in run time "OnJNIPrompt"]:

Code: Pascal  [Select][+][-]
  1.  jImageView1.ImageIdentifier:= "ic_launcher";
  2.  

Title: Re: Android Module Wizard
Post by: truetom on October 11, 2015, 07:44:24 am
One question , I have not yet figured out how to change the version number of my application . I thought he did on automatically each compilation , but I do not think so . Because when I go to install the apk file on my Android device did not update the version . Why? Who tells me how to do?

Hello xinyiman,

You can open  the file AndroidManifest.xml , edit like this:
    android:versionCode="2"  //this is application version number.
    android:versionName="1.1"  //this is show to users , not really version number.

Thanks and best regards!
Title: Re: Android Module Wizard
Post by: almora on October 11, 2015, 08:34:36 am
Laz4android + Android Module Wizard + LazToApk  = android app.

Is this possible?
No eclipse install..
Title: Re: Android Module Wizard
Post by: jmpessoa on October 11, 2015, 05:38:15 pm
Hello almora!

Yes, you can use  LazToApk to get the tools [sdk, ndk, ....]

and  Laz4android + Android Module Wizard to produce [bulid], run/install the apk!

From "readme_get_start.txt":

Quote
Here is a  rapid "get_start" for windows: "Laz4Android + Lazaru Azandroid Module Wizard"

Note 1:   for Linux:  go to " lazandroidmodulewizard folder  "...\linux"
   and read: "new_how_to_install_by_renabor.txt"

I. Infrastructure

.Java  sdk_x86 [32 bits]

.Android sdk, NDK-r10e

.Laz4Android [All in one!] =

                   Last update:2015-10-02
                   FPC: 3.1.1 trunk svn 31903 win32/arm-android/i386-android/jvm-android
                   Lazarus:1.5 trunk svn 49903
                   Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)
         :To Install [*.7z] --> "build.bat"

.Android sdk

.Android ndk-r10e   -    this version is required by "Laz4Android" 
         http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86.exe

.Ant [to build Apk]
   http://ant.apache.org/bindownload.cgi
   Simply extract the zip file to a convenient location...

.Eclipse is not mandatory!  [but, to  facility, all projects [and Demos ] are Eclipse compatible!] 


II. LAMW:  Lazarus Android Module Wizard

   ref. https://github.com/jmpessoa/lazandroidmodulewizard

   .Install ordem.

      tfpandroidbridge_pack.lpk
      lazandroidwizardpack.lpk
      amw_ide_tools.lpk     [../ide-tools]

III. USE

1. Configure Paths:

   Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" -->  "Path Settings ..."

2. New Project [thanks to @Developing!]     

   After install "LAMW" packages:

   2.1-From Lazarus IDE select "Project" -> "New Project"

   ref. https://jmpessoa.opendrive.com/files?Ml85OTEwMDQ3OV9BRW45VA

   2.2-From displayed dialog  select "JNI Android Module [Lamw GUI]"    


   2.3-Press OK Button.

   2.4. From form "Android Module wizard: Configure Project..." [Workspace Form]

      ref. https://jmpessoa.opendrive.com/files?Ml85OTEwMDU1Nl9YVE5qUg

   2.4-Fill/complete the field:
      "Path to workspace [project folder]" 
      example c:\LamwProjects

   2.5-Fill/complete the field:
      "New Project Name  [or Selec
      example: MyProject1
      [This is your Android App/Apk name]

   2.6-Select your Sdk [installed] Platform:
      example: Jelly Bean 4.1

   2.7-[MinSdk] Select the  min. Sdk Api to compile your project:
      example: 15

   2.8-[TagetApi] Select the target [api] device
      example: 19

   2.9-Select Instruction:
      example: ARMv6
      
        2.10. If Arm then Select Fpu:
      example: Soft

   2.11-Save All [unit1.pas] in path that is showed ...

3. From "Android Bridge" component tab drag/drop a jTextView in jForm
      set property: PosRelativeToParent  = [rpTop,rpCenterHorizontal]

4. From "Android Bridge" component tab drag/drop a jButton     in jForm
     set property: Anchor = jTextView1
     set property: PosRelativeToAnchor : [raBelow]
     set property:PosRelativeToParent = [rpCenter]
     write code for event property "OnClick"  =  ShowMessage('Hello!')

5.  Lazarus IDE menu "Run" ---> "Buld"   

6. Connect your Device to Computer [usb] and configure it to "debug mode"     

   "App settings"  ---> more/aditional -- developer options (*): 
   stay awake  [checked!]
   usb debugging [checked!]
   verify apps via usb [checked!]

   (*)PANIC! Go to Google search with "android usb debugging <device name>" to get the operating mode adapted to your device...
   
   ex. Galaxy S3/S4 --> app settings --> about -->> Build number -->> [tap,tap,tap,...]
        ex. MI 2 --> app settings --> about -->> MIUI Version -->> [tap,tap,tap,...]


7.Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run" [Congratulations!!!]

8.PANIC!!! Fail to buid "Apk"

   .Try change project  "AndroidManifest.xml" according your system installation....

      <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17"/>

      hint: other target:   "android:targetSdkVersion" !!
      
   .Change your project "build.xml"  according your system installation...

      <property name="target"  value="android-17"/>


9. How to configure a Demo to Use/Test:

      .Lazarus IDE menu Open a [*.lpi] Demo Project   [...\jni]

      .Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" -->  "Change Project [*.lpi] Ndk Path"

      .set your "NDK" path!

      .change/edit project "build.xml"   according your system..

      <property name="sdk.dir" location="C:\adt32\sdk"/>


10. There are some others docs:   

   "install_tutorial.txt"
         and
   "install_tutorial_eclipse_users.txt"


Thank you!
Title: Re: Android Module Wizard
Post by: DelphiFreak on October 11, 2015, 07:52:33 pm
Hi,
would it be a big change to add "Android Module Wizard" and package "CustomDrawn"  into the Laz4Android package? (truetom??)
If this would be added, the user's could use laztoapk to get all stuff installed in one go?

Regards,
Sam
Title: Re: Android Module Wizard
Post by: almora on October 12, 2015, 12:31:47 pm
Thank you....
Title: Re: Android Module Wizard
Post by: euller on October 15, 2015, 10:10:39 pm
Just a silly question here:

About jForm.OnRotate(Sender: TObject; rotate: integer; var rstRotate: integer), apart from sender, what those parameters mean?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 16, 2015, 08:18:53 pm
Hello Euller!

if rotate = 1 --> device is in vertical    [default position]

if rotate = 2 ->  device is in horizontal

 var rstRotate <<----  you can force to 1 or 2!    {default/indifferent = 0}

Note: You can try "AppCameraDemo" demo
Title: Re: Android Module Wizard
Post by: Leledumbo on October 17, 2015, 07:26:06 am
Hello Euller!

if rotate = 1 --> device is in vertical    [default position]

if rotate = 2 ->  device is in horizontal

 var rstRotate <<----  you can force to 1 or 2!    {default/indifferent = 0}

Note: You can try "AppCameraDemo" demo
Wouldn't it be better to use enum instead of integer?
Title: Re: Android Module Wizard
Post by: truetom on October 17, 2015, 02:21:17 pm
Hello jmpessoa,

I have updated the new version laz4android-50093,
I also used the new LAMW which is download today.
But when I create new project with JNI Android Module (Lamw NoGUI or Lamw GUI),
it only show me a error : "List index (-1) out of bounds".
Please help me to fix this problem, thank you!

Thanks and best regards!
Title: Re: Android Module Wizard
Post by: euller on October 17, 2015, 02:26:39 pm
Wouldn't it be better to use enum instead of integer?

I think the same way. This isn't the place to discuss where and when to use enums, but some meaningful names are helpful to the person using the tool. But this isn't a major flaw that compromises the usability of LAMW, it's just an odd design choice that isn't prejudicial to the development cycle.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 17, 2015, 03:30:50 pm
@TrueTom

Quote
I create new project with JNI Android Module (Lamw NoGUI or Lamw GUI),
it only show me a error : "List index (-1) out of bounds".

Someone else has already reported this issue/bug ...I think it may be related to fill some listbox/combox in unit "uformworkspace.pas" ...  still can not identify why it occurs in some case ... I will continue trying to fix it!

@Euller and Leledumbo

Yes, the code has [some/many] immature design... all suggestions are welcome
[we can improve it]!

Thanks to All!
Title: Re: Android Module Wizard
Post by: euller on October 17, 2015, 04:18:00 pm
An thing that I've just found about jDialogYN, let me show with some code

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.DoBar;
  2. begin
  3.    DoFoo('yeah');// something that may fail
  4.    jDialogYN1.Show
  5. end;
  6.  
  7. procedure TAndroidModule1.jDialogYN1ClickYN(Sender: TObject; YN: TClickYN);
  8. begin
  9.    if YN = clickNo then
  10.      DoBar
  11. end;
  12.  
  13. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
  14. begin
  15.    jDialogYN1.No:= 'No';
  16.    jDialogYN1.Yes:= 'Yes';
  17.    jDialogYN1.Msg:= 'The application has executed DoFoo?';
  18.    jDialogYN1.Title:= 'Foo';
  19. end;
  20.  

Well, this should create an loop, where DoBar calls DoFoo to do its thing that may fail, and that fail is obvious to the user, and then a dialog shows up asking the user if the operation was done. If it was, the program flow should return to normal, if it wasn't, DoBar is called again.

But I've noticed that, when I try to do it, there is no loop, jDialogYN1 is not showing again? Is that supposed to happens?
Title: Re: Android Module Wizard
Post by: truetom on October 17, 2015, 04:25:56 pm
@jmpessoa

Hello jmpessoa,

I have found this problem,and fixed this problem.
When the error is show , I found in the file "JNIAndroidProject.ini / AndroidPlatform=-1" , then I change it to 0 ,this error not show.
You are right , it's in the file "uformworkspace.pas" , read the "FAndroidPlatform" is not validity, I change ListBoxPlatform.ItemIndex:=0 to fixed this problem.

Thanks and best regards!
Title: Re: Android Module Wizard
Post by: A.S. on October 17, 2015, 04:29:55 pm
truetom, Check the last changes, please.
Title: Re: Android Module Wizard
Post by: truetom on October 17, 2015, 05:05:27 pm
truetom, Check the last changes, please.

Hello A.S.
Now it's works ok!

Thanks and best regards!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 26, 2015, 07:24:16 pm
Hello All!

NEW!!

Added [initial]  "Android Themes" support!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!
Title: Re: Android Module Wizard
Post by: arezmr on October 27, 2015, 05:07:33 am
i have problem installing apk on handset.
Apk build succesfully but apk cant install on handset, whats the prblm

position :
- lazarus 1.4.4 with Fpc 3.1.1 put from laz4android bundle (replaced 2.4.6 )
- android-ndk-r10c
- jdk1.8.0_25
- apache-ant-1.9.6
- SDK 23.0.1

 project option
- NDK platform  : 16
- MinSDKApI  : 17
- TargetSDKApI : 17


other problem when i'm using laz4android bundle (lazarus 5), i cant install androidbridge and android wizard. here the message :
Panic: make: Entering directory `C:/Program Files/laz4android'
Panic: make: Leaving directory `C:/Program Files/laz4android'

thanks for help.
Title: Re: Android Module Wizard
Post by: renabor on October 27, 2015, 01:27:39 pm
Hello All!

NEW!!

Added [initial]  "Android Themes" support!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!

Great job!

Thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on October 27, 2015, 05:02:19 pm

Hello arezmr!

1.

Quote
android-ndk-r10c

The updated laz4android is for "android-ndk-r10e"  <<--- "e"

2.
Quote
C:/Program Files/laz4android'

Your laz4android  install path has "space" .... try "C:/laz4android"

Title: Re: Android Module Wizard
Post by: arezmr on October 28, 2015, 12:07:35 pm
Hei jmpessoa
its really working now, its great!!
thanks for helping.  :)

having prblm  again :D

1. building apk for the first compile always error with this msg :
C:\Android SDK\tools\ant\build.xml:716: The following error occurred while executing this line:
but for the second compiling  and next compiling succesfully and working install to the handset

2. screen rosolution too  small. how to fit componnt with 720 x 1280 pixels or streching with all size screen?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 28, 2015, 03:29:21 pm

Hello arezmr!

1. and 2.

Please, zip and send me your test project..... [put it in some open drive]


Quote
screen rosolution too  small. how to fit componnt with 720 x 1280 pixels or streching with all size screen?

We do not have problem with real device screen size... only with AVD/emulator
Title: Re: Android Module Wizard
Post by: dinmil on November 04, 2015, 05:34:57 pm
Hello. I'm new to this thread. I have one question regarding jHtppClient.
Is it possible to retrieve gzip response from server and somehow ungzipit via jHttpClient component.


var MyString
begin
  jHttpClient1.AddClientHeader('Accept-Encoding', 'gzip');
  MyString := jHttpClient1.Get('http://some.server.which.return.gzip');
  // MyString is compressed - how to uncompress
end;

Second question. Is there any way to save String to file which is available (visible) via usb cable and some storage folder on phone

Regards, Dinko
Title: Re: Android Module Wizard
Post by: jmpessoa on November 05, 2015, 01:04:56 am
Hello dinmil!

Quote
Second question. Is there any way to save String to file which is available (visible) via usb cable and some storage folder on phone...

Yes! You can use jTextFileManager component and "CopyFile" ...

[see demo AppShareFileDemo1]

Code: Pascal  [Select][+][-]
  1.    //myString: string;
  2.    
  3.    //save to Internal App Storage
  4.     jTextFileManager1.SaveToFile(myString, 'hello.txt');
  5.  
  6.    //copy to "public" folder download ...  
  7.    Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirInternalAppStorage)+'/hello.txt',
  8.                            Self.GetEnvironmentDirectoryPath(dirDownloads)+'/hello.txt');  
  9.  
  10.  

For now I could not answer question 1... please try it!
Title: Re: Android Module Wizard
Post by: dinmil on November 05, 2015, 02:13:24 pm
I checked AppShareFileDemo and tried to Copy hello.txt to /download/public.
Function returns that Copy is OK but it is not visible ouside of phone. Even file manager of phone can not find the file.
Path say that this is /emulated/0/downloads  path or something like that.
I have HTC 310 for test which is not routed.

About httpclient.get method. This method returns utf unicode string. So if server returns gzip of 33 bytes it is converted to unicode of 63 bytes.
Is there some function which will convert unicode string to byte array or stream? This will solve problem.
Or even better, is there some function which will get http data in stream format or byte array?

So far, I think this project is excellent. Installation is little bit painful, but once setup is finished almost everything work OK.

Regards, Dinko
Title: Re: Android Module Wizard
Post by: dinmil on November 05, 2015, 02:50:21 pm
Copy is OK. After installing and starting Total commander for Android I was able to find the files.

So it seems one problem is solved, still stays jHttpClient and gzip.

Regards, Dinko
Title: Re: Android Module Wizard
Post by: jmpessoa on November 05, 2015, 03:07:55 pm
Quote
Is there some function which will convert unicode string to byte array or stream? This will solve problem....

Good! Now we have a Pascal question.... maybe someone can help here!

Quote
. Installation is little bit painful, but once setup is finished almost everything work OK

Yes, we need improve docs and tutorial.... suggestions are welcomed!

Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 09, 2015, 01:39:57 pm
Hi jmpessoa, i am developing an english study app, but it has a problem with jactionbartab

When I press on image button , tabs will be created and show, but if i want back home page, tabs  still be there ( on the top of screen)

I tried to use both command

self.RemoveAllTabsActionBar();
jactionbartab1.RemoveAllTabs();   

but they can't solve this
You can see image below to understand more
Title: Re: Android Module Wizard
Post by: renabor on November 09, 2015, 05:21:03 pm
Hi jmpessoa, i am developing an english study app, but it has a problem with jactionbartab

When I press on image button , tabs will be created and show, but if i want back home page, tabs  still be there ( on the top of screen)

I tried to use both command

self.RemoveAllTabsActionBar();
jactionbartab1.RemoveAllTabs();   

but they can't solve this
You can see image below to understand more

Hello m4u_hoahoctro!

I use this method in order to remove tabs:

Code: [Select]
  jMenu1.Clear();
  self.RemoveAllTabsActionBar();
  jMenu1.InvalidateOptionsMenu();

be sure that in your controls.java the method RemoveAllTabsActionBar is updated:

Code: [Select]
public void RemoveAllTabsActionBar() {
ActionBar actionBar = this.controls.activity.getActionBar();
actionBar.removeAllTabs();
        this.controls.activity.invalidateOptionsMenu();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); //API 11 renabor
}


Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 13, 2015, 02:54:01 pm
May be i was wrong when i decided to update lamw and laz4android
I updated:
lamw's lastest version
laz4android 1.4
android ndk 10e

I confirgured paths setting, and when I choose Update Code menu ( rebuild .so lib): This error shows: Priviledged instruction ( below image )

and so I choosed Cancel to reopen laz4, and I tried to open my project ( created by older version of lamw and laz4 ( 1.3) )
but I still got more errors ( Can see  by images I sent below )

http://i.imgur.com/3iBUa1p.png (http://i.imgur.com/3iBUa1p.png)

http://i.imgur.com/lc36CtX.png (http://i.imgur.com/lc36CtX.png)


after some hours, I used backup version of my project and reopen it
everything is ok until I choose Run and build apk file menu
As this image, I choosed Yes to all because i updated ndk to r10e
http://i.imgur.com/wtXyjbI.png (http://i.imgur.com/wtXyjbI.png)

then a dialog appears, and i dont know which  should be chosen
 :o
http://i.imgur.com/LvTGDdO.png (http://i.imgur.com/LvTGDdO.png)

I need a solution from others, thanks  %) %) %)
Title: Re: Android Module Wizard
Post by: jmpessoa on November 13, 2015, 03:46:22 pm
Hello M4u

1.

 You need download ndk10e


2.

Go to "C:\laz4android\config"

and change  "JNIAndroidProject.ini"  lines:

PathToAndroidNDK=your "ndk10e" path
NDK=3


3.

For old projects open "*.lpi" and change NDK path and replace "4.6" to "4.9"

 
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 14, 2015, 06:03:08 am
Hello M4u

2.

Go to "C:\laz4android\config"

and change  "JNIAndroidProject.ini"  lines:

PathToAndroidNDK=your "ndk10e" path
NDK=3


I set up laz4android in D drive, but I dont find any file whose name JNIAndroidProject.ini in config folder ( below image )
http://i.imgur.com/KBa7phs.png (http://i.imgur.com/KBa7phs.png)

 

Title: Re: Android Module Wizard
Post by: Leledumbo on November 14, 2015, 08:05:37 am
I set up laz4android in D drive, but I dont find any file whose name JNIAndroidProject.ini in config folder ( below image )
http://i.imgur.com/KBa7phs.png (http://i.imgur.com/KBa7phs.png)
JNIAndroidProject.ini is located in lazarus configuration directory, not your app (it's global for all of your LAMW projects).
Title: Re: Android Module Wizard
Post by: jmpessoa on November 14, 2015, 10:41:19 am
Yes,

Go to "..\laz4android\config"     // << -----------------

and change  "JNIAndroidProject.ini"  lines:

PathToAndroidNDK=your "ndk10e" path
NDK=3


Well, if  you not have "JNIAndroidProject.ini"  in  your new laz4android install, then
you can copy from the old install [and fix it]

or:

go to Lazarus IDE menu  ---> Tools ---> [Lamw] ---> Paths Settings
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 14, 2015, 11:54:46 am
problem was solved. thanks to all  :) :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on December 07, 2015, 12:43:38 pm
after updating lamw, i am having a new problem
I tried making an app loading image from internet
I used code as I did before, but the app will be closed ( crash )

asynctask do in background

Code: Pascal  [Select][+][-]
  1. if actiontype=8 then
  2.  begin
  3.  FImageBitmap:=jImageFileManager1.LoadFromURL('http://miftyisbored.com/wp-content/uploads/2013/07/nature-sound-spa-app.png');
  4.  FImageBitmap:=Get_jObjGlobalRef(FImageBitmap);
  5.  end;              
  6.  

post excute:

Code: Pascal  [Select][+][-]
  1. if actiontype=8 then
  2.  begin
  3.  if FImageBitmap<>nil then
  4.   begin
  5.   jImageview11.SetImageBitmap(FImageBitmap);
  6.   Delete_jGlobalRef(FImageBitmap);
  7.   FImageBitmap:=nil;
  8.   end;
  9.  end;        

and the button runs that codes

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jImageView12Click(Sender: TObject);
  2. begin
  3.   jtextview1.text:=suggestion;
  4.   actiontype:=8;
  5.   if not jasynctask1.Running=true then
  6.   begin
  7.   jdialogprogress1.Start;
  8.   jasynctask1.Execute;
  9.   end;
  10.    ttime:=30;
  11.    jtimer1.enabled:=true;
  12.  
  13. end;          

i tested many times, and errors always appears if I use code:
Code: Pascal  [Select][+][-]
  1. FImageBitmap:=jImageFileManager1.LoadFromURL('http://miftyisbored.com/wp-content/uploads/2013/07/nature-sound-spa-app.png');
  2.  FImageBitmap:=Get_jObjGlobalRef(FImageBitmap);          

( many it caused all problem )

I dont know what should do next or fix it  %)
Title: Re: Android Module Wizard
Post by: xinyiman on December 08, 2015, 06:19:10 pm
Hello guys , there is a demo or an example to generate an Graph Lines with LAMW

Like this:

http://blog.andreaventuri.it/wp-content/uploads/2010/03/linegraph.jpg
Title: Re: Android Module Wizard
Post by: jmpessoa on December 09, 2015, 04:02:52 pm
@m4u_hoahoctro

Please, put here your "unit1.pas" ...

@xinyiman

I have a multi-platform graphics toolkit here:

https://github.com/jmpessoa/tfpdxfwritebridge   [install first]
https://github.com/jmpessoa/tfpnoguigraphicsbridge

You can get  "AppTFPNoGUIGraphicsBridgeDemo1" in "...\demos\Eclipse"

I will try to do a new android demo to mimic your example...

See the windows preview [attachment]... the windows code is here:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, FPNoGUIGraphicsBridge, ViewPort, Forms, Controls,
  9.   Graphics, Dialogs, ExtCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  17.     PaintBox1: TPaintBox;
  18.     Panel1: TPanel;
  19.     Panel2: TPanel;
  20.     ViewPort1: TViewPort;
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure PaintBox1Paint(Sender: TObject);
  23.   private
  24.     { private declarations }
  25.   public
  26.     { public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. uses
  37.   GeometryUtilsBridge, fpcolorbridge;
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.FormCreate(Sender: TObject);
  42. begin
  43.    ViewPort1.Height:= PaintBox1.Height;
  44.    ViewPort1.Width:= PaintBox1.Width;
  45.  
  46.    ViewPort1.SetScaleXY(0 {minx}, 15 {maxx}, -5 {miny}, 15 {maxy});
  47.  
  48.    FPNoGUIGraphicsBridge1.PathToFontFile:= 'C:\Windows\Fonts\LUCON.TTF';
  49.    FPNoGUIGraphicsBridge1.SetSurfaceSize(PaintBox1.Width,PaintBox1.Height);
  50.  
  51.    //FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  52.    FPNoGUIGraphicsBridge1.PaintViewPort;
  53.    FPNoGUIGraphicsBridge1.PaintGrid(True);
  54.  
  55.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(4,10),ToRealPoint(5,11) ],'','');
  56.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(4,10),ToRealPoint(4+0.1,10) ],'','');
  57.  
  58.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(5,11),ToRealPoint(6,11) ],'','');
  59.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(5,11),ToRealPoint(5+0.1,11) ],'','');
  60.  
  61.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(6,11),ToRealPoint(7,12) ],'','');
  62.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(6,11),ToRealPoint(6+0.1,11) ],'','');
  63.  
  64.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(7,12),ToRealPoint(8,12) ],'','');
  65.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(7,12),ToRealPoint(7+0.1,12) ],'','');
  66.  
  67.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(8,12),ToRealPoint(10,13) ],'','');
  68.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(8,12),ToRealPoint(8+0.1,12) ],'','');
  69.  
  70.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(10,13),ToRealPoint(11,14) ],'','');
  71.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(10,13),ToRealPoint(10+0.1,13) ],'','');
  72.  
  73.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(11,14),ToRealPoint(12,15) ],'','');
  74.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(11,14),ToRealPoint(11+0.1,14) ],'','');
  75.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(12,15),ToRealPoint(12+0.1,15) ],'','');
  76.  
  77.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(4,-5),ToRealPoint(5,0) ],'','');
  78.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(4,-5),ToRealPoint(4+0.1,-5) ],'','');
  79.  
  80.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(5,0),ToRealPoint(6,7) ],'','');
  81.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(5,0),ToRealPoint(5+0.1,0) ],'','');
  82.  
  83.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(6,7),ToRealPoint(7,10) ],'','');
  84.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(6,7),ToRealPoint(6+0.1,7) ],'','');
  85.  
  86.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(7,10),ToRealPoint(8,10) ],'','');
  87.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(7,10),ToRealPoint(7+0.1,10) ],'','');
  88.  
  89.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(8,10),ToRealPoint(10,11) ],'','');
  90.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(8,10),ToRealPoint(8+0.1,10) ],'','');
  91.  
  92.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(10,11),ToRealPoint(11,12) ],'','');
  93.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(10,11),ToRealPoint(10+0.1,11) ],'','');
  94.  
  95.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(11,12),ToRealPoint(12,14) ],'','');
  96.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(11,12),ToRealPoint(11+0.1,12) ],'','');
  97.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(12,14),ToRealPoint(12+0.1,14) ],'','');
  98.  
  99.    //ViewPort1.PenColor:= colbrRed;  //default
  100.    FPNoGUIGraphicsBridge1.DrawEntities('red');
  101.  
  102.    ViewPort1.PenColor:= colbrBlue;
  103.    FPNoGUIGraphicsBridge1.DrawEntities('blue');
  104.  
  105.    PaintBox1.Invalidate;
  106. end;
  107.  
  108. procedure TForm1.PaintBox1Paint(Sender: TObject);
  109. begin
  110.   FPNoGUIGraphicsBridge1.CopyToCanvas(PaintBox1.Canvas);
  111. end;
  112.  
  113. end.
  114.  
  115.  
Title: Re: Android Module Wizard
Post by: jmpessoa on December 10, 2015, 05:44:58 am
Hello xinyiman!

The android demo to mimic your example was added to github repository....

You can get  "AppTFPNoGUIGraphicsBridgeDemo2" in "...\demos\Eclipse"
[please, read the "readme.txt" in "..\jni"]

note:  you need the graphics toolkit from here:

https://github.com/jmpessoa/tfpdxfwritebridge  [install first]
https://github.com/jmpessoa/tfpnoguigraphicsbridge
                 

the android preview [attachment]... the android code is here:

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo2\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  10.     Laz_And_Controls_Events, AndroidWidget, FPNoGUIGraphicsBridge, ViewPort;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  18.     jBitmap1: jBitmap;
  19.     jButton1: jButton;
  20.     jImageView1: jImageView;
  21.     jPanel1: jPanel;
  22.     jPanel2: jPanel;
  23.     jTextView1: jTextView;
  24.     ViewPort1: TViewPort;
  25.     procedure jButton1Click(Sender: TObject);
  26.   private
  27.     {private declarations}
  28.   public
  29.     {public declarations}
  30.   end;
  31.  
  32. var
  33.   AndroidModule1: TAndroidModule1;
  34.   PGlobalDirectImagePixel: PJByte;
  35.  
  36. implementation
  37.  
  38. {$R *.lfm}
  39.  
  40. uses
  41.   FPColorBridge, GeometryUtilsBridge;
  42.  
  43. { TAndroidModule1 }
  44.  
  45. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  46. var
  47.   jGraphicsBuffer: jObject;
  48.   w, h: integer;
  49. begin
  50.   w:= jPanel2.Width;
  51.   h:= jPanel2.Height;
  52.  
  53.   ViewPort1.Height:= h;
  54.   ViewPort1.Width:= w;
  55.  
  56.   ViewPort1.SetScaleXY(0 {minx}, 15 {maxx}, -5 {miny}, 15 {maxy});
  57.  
  58.   FPNoGUIGraphicsBridge1.SetSurfaceSize(w,h);
  59.   FPNoGUIGraphicsBridge1.PathToFontFile:= '/system/fonts/Roboto-Regular.ttf'; //or DroidSerif-Bold.ttf
  60.  
  61.   //FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  62.   FPNoGUIGraphicsBridge1.PaintViewPort;
  63.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  64.  
  65.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(4,10),ToRealPoint(5,11) ],'','');
  66.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(4,10),ToRealPoint(4+0.1,10) ],'','');
  67.  
  68.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(5,11),ToRealPoint(6,11) ],'','');
  69.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(5,11),ToRealPoint(5+0.1,11) ],'','');
  70.  
  71.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(6,11),ToRealPoint(7,12) ],'','');
  72.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(6,11),ToRealPoint(6+0.1,11) ],'','');
  73.  
  74.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(7,12),ToRealPoint(8,12) ],'','');
  75.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(7,12),ToRealPoint(7+0.1,12) ],'','');
  76.  
  77.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(8,12),ToRealPoint(10,13) ],'','');
  78.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(8,12),ToRealPoint(8+0.1,12) ],'','');
  79.  
  80.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(10,13),ToRealPoint(11,14) ],'','');
  81.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(10,13),ToRealPoint(10+0.1,13) ],'','');
  82.  
  83.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(11,14),ToRealPoint(12,15) ],'','');
  84.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(11,14),ToRealPoint(11+0.1,14) ],'','');
  85.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(12,15),ToRealPoint(12+0.1,15) ],'','');
  86.  
  87.   //legend
  88.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(14,5),ToRealPoint(15,5) ],'','');
  89.   FPNoGUIGraphicsBridge1.AddEntity('red','Text',[ToRealPoint(15,5)],'Feb','');
  90.  
  91.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(4,-5),ToRealPoint(5,0) ],'','');
  92.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(4,-5),ToRealPoint(4+0.1,-5) ],'','');
  93.  
  94.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(5,0),ToRealPoint(6,7) ],'','');
  95.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(5,0),ToRealPoint(5+0.1,0) ],'','');
  96.  
  97.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(6,7),ToRealPoint(7,10) ],'','');
  98.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(6,7),ToRealPoint(6+0.1,7) ],'','');
  99.  
  100.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(7,10),ToRealPoint(8,10) ],'','');
  101.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(7,10),ToRealPoint(7+0.1,10) ],'','');
  102.  
  103.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(8,10),ToRealPoint(10,11) ],'','');
  104.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(8,10),ToRealPoint(8+0.1,10) ],'','');
  105.  
  106.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(10,11),ToRealPoint(11,12) ],'','');
  107.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(10,11),ToRealPoint(10+0.1,11) ],'','');
  108.  
  109.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(11,12),ToRealPoint(12,14) ],'','');
  110.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(11,12),ToRealPoint(11+0.1,12) ],'','');
  111.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(12,14),ToRealPoint(12+0.1,14) ],'','');
  112.  
  113.   //legend
  114.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(14,4),ToRealPoint(15,4) ],'','');
  115.   FPNoGUIGraphicsBridge1.AddEntity('blue','Text',[ToRealPoint(15,4)],'Jan','');
  116.  
  117.   //ViewPort1.PenColor:= colbrRed;  //default: design time
  118.   FPNoGUIGraphicsBridge1.DrawEntities('red');
  119.  
  120.   ViewPort1.PenColor:= colbrBlue;
  121.   FPNoGUIGraphicsBridge1.DrawEntities('blue');
  122.  
  123. (*
  124.    //or simply
  125.    ViewPort1.PenColor:= colbrGreen;
  126.    FPNoGUIGraphicsBridge1.DrawPath([ToRealPoint(3,3), ToRealPoint(4,4), ToRealPoint(5,5),ToRealPoint(6,6), ToRealPoint(7,7), ToRealPoint(8,8)]);
  127.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(3,3){center},ToRealPoint(3+0.1,3) {rX}]);
  128.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(4,4){center},ToRealPoint(4+0.1,4) {rX}]);
  129.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(5,5){center},ToRealPoint(5+0.1,5) {rX}]);
  130.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(6,6){center},ToRealPoint(6+0.1,6) {rX}]);
  131.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(7,7){center},ToRealPoint(7+0.1,7) {rX}]);
  132.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(8,8){center},ToRealPoint(8+0.1,8) {rX}]);
  133.    FPNoGUIGraphicsBridge1.DrawFillRectangle([ToRealPoint(9.5,8.0),ToRealPoint(10,7)]); {left-top, right-bottom}
  134.    FPNoGUIGraphicsBridge1.TextOut(ToRealPoint(10.2,7), 'Mar', 22, colbrGreen);
  135. *)
  136.  
  137.   jGraphicsBuffer:= jBitmap1.GetByteBuffer(w,h);
  138.  
  139.   PGlobalDirectImagePixel:= jBitmap1.GetDirectBufferAddress(jGraphicsBuffer);
  140.  
  141.   FPNoGUIGraphicsBridge1.Surface.GetRGBAGraphics(PGlobalDirectImagePixel);
  142.  
  143.   jImageView1.SetImageBitmap(jBitmap1.GetBitmapFromByteBuffer(jGraphicsBuffer, w, h));
  144. end;
  145.  
  146. end.
  147.  

Title: Re: Android Module Wizard
Post by: xinyiman on December 17, 2015, 08:46:12 pm
Hello, I would have a couple of questions. How do I ensure that a jtextbox accept only numbers?

How do I use the JTIMER?

Are there examples?

Then I wanted to know, there is a guide that explains clearly the best methods to manage the look and feel of an application made with  Android (LAMW)?

Thank you
Title: Re: Android Module Wizard
Post by: truetom on December 18, 2015, 02:03:49 am
Hello, I would have a couple of questions. How do I ensure that a jtextbox accept only numbers?

How do I use the JTIMER?

Are there examples?

Then I wanted to know, there is a guide that explains clearly the best methods to manage the look and feel of an application made with  Android (LAMW)?

Thank you

Hello,

try  to answer your question.

1. set Property InputTypeEx:= itxNumber;
2. When jFrom create , set jTimer enabled to true, jTimer1.enabled:=true;

Thanks and best regard!
Title: Re: Android Module Wizard
Post by: jmpessoa on December 18, 2015, 02:33:49 am

Quote
...there is a guide that explains clearly the best methods to manage the look and feel of an application made with  Android (LAMW)?

LAMW now support  android "themes"...  so you can get the android  "look and feel" by Just

selecting a theme [create new project]:

   DeviceDefault
   Holo.Light.DarkActionBar 
   Holo.Light 
   Holo
   Material.Light.DarkActionBar
   Material.Light
   Material
Title: Re: Android Module Wizard
Post by: jmpessoa on December 22, 2015, 05:20:28 pm

Hi!

Following the suggestion and request by xinyiman, 

There are news "Lamw" demos for "chart" [https://github.com/jmpessoa/lazandroidmodulewizard]:

AppTFPNoGUIGraphicsBridgeDemo4 [DataPieSlices and DataLines graphics]  <<--- picture attachment!
AppTFPNoGUIGraphicsBridgeDemo5  [DataBars and DataHistogram graphics]

warning 1: read the "readme.txt" in  project  "...\jni" folder

warning 2. install the "NoGUIGraphicsBridge" package from here :

https://github.com/jmpessoa/tfpnoguigraphicsbridge   
[a native pascal multi-platform graphics toolkit wrapper over Free Pascal "fcl-image" + freetype]


AppTFPNoGUIGraphicsBridgeDemo4  "unit1.pas" code "look and feel" is here:

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo4\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  10.     Laz_And_Controls_Events, AndroidWidget, FPNoGUIGraphicsBridge, ViewPort;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  18.     jBitmap1: jBitmap;
  19.     jButton1: jButton;
  20.     jImageView1: jImageView;
  21.     jPanel1: jPanel;
  22.     jPanel2: jPanel;
  23.     jTextView1: jTextView;
  24.     ViewPort1: TViewPort;
  25.     ViewPort2: TViewPort;
  26.     procedure jButton1Click(Sender: TObject);
  27.   private
  28.     {private declarations}
  29.   public
  30.     {public declarations}
  31.   end;
  32.  
  33. var
  34.   AndroidModule1: TAndroidModule1;
  35.   PGlobalDirectImagePixel: PJByte;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. uses
  42.   FPColorBridge, GeometryUtilsBridge;
  43.  
  44. { TAndroidModule1 }
  45.  
  46. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  47. var
  48.   jGraphicsBuffer: jObject;
  49.   w, h: integer;
  50. begin
  51.   w:= jPanel2.Width;
  52.   h:= jPanel2.Height;
  53.  
  54.   ViewPort1.XLeft:= 0;
  55.   ViewPort1.YTop:= 0;
  56.   ViewPort1.Height:= Trunc(h/2);
  57.   ViewPort1.Width:= w;
  58.  
  59.   ViewPort1.SetScaleXY(0 {minx}, 10 {maxx}, 0 {miny}, 10 {maxy});
  60.  
  61.   FPNoGUIGraphicsBridge1.SetSurfaceSize(w,h);
  62.   FPNoGUIGraphicsBridge1.PathToFontFile:= '/system/fonts/Roboto-Regular.ttf'; //or DroidSerif-Bold.ttf
  63.  
  64.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  65.   FPNoGUIGraphicsBridge1.PaintViewPort;
  66.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  67.  
  68.   FPNoGUIGraphicsBridge1.DrawDataPieSlices([ToRealPoint(1,8),ToRealPoint(7,2)],
  69.                                            [ToSlice(45,'Jan', colbrLightGray),
  70.                                             ToSlice(15,'Fev', colbrYellow),
  71.                                             ToSlice(40,'Mar', colbrMoccasin),
  72.                                             ToSlice(40,'Abr', colbrLightBlue),
  73.                                             ToSlice(40,'Mai', colbrLime),
  74.                                             ToSlice(45,'Jun', colbrLightSalmon)], False);
  75.   ViewPort2.XLeft:= 0;
  76.   ViewPort2.YTop:= Trunc(h/2);
  77.   ViewPort2.Height:= Trunc(h/2);
  78.   ViewPort2.Width:= w;
  79.   ViewPort2.SetScaleXY(0 {minx}, 14 {maxx}, -5 {miny}, 15 {maxy});
  80.  
  81.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort2;
  82.   FPNoGUIGraphicsBridge1.PaintViewPort;
  83.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  84.  
  85.   //
  86.   FPNoGUIGraphicsBridge1.DrawDataLine([ToRealPoint(4,10),
  87.                                    ToRealPoint(5,11),
  88.                                    ToRealPoint(6,11),
  89.                                    ToRealPoint(7,12),
  90.                                    ToRealPoint(8,12),
  91.                                    ToRealPoint(10,13),
  92.                                    ToRealPoint(11,14),
  93.                                    ToRealPoint(12,15)],
  94.                                    ToLegend('Jan', colbrBlue, 14.1,9));
  95.  
  96.   FPNoGUIGraphicsBridge1.DrawDataLine([ToRealPoint(4,-5),
  97.                                    ToRealPoint(5,0),
  98.                                    ToRealPoint(6,7),
  99.                                    ToRealPoint(7,10),
  100.                                    ToRealPoint(8,10),
  101.                                    ToRealPoint(10,11),
  102.                                    ToRealPoint(11,12),
  103.                                    ToRealPoint(12,14)],
  104.                                    ToLegend('Fev', colbrSalmon, 14.1,7));
  105.  
  106.   FPNoGUIGraphicsBridge1.DrawDataLine([ToRealPoint(4,0),
  107.                                    ToRealPoint(5,6),
  108.                                    ToRealPoint(6,9),
  109.                                    ToRealPoint(7,11),
  110.                                    ToRealPoint(8,11),
  111.                                    ToRealPoint(10,12),
  112.                                    ToRealPoint(11,13),
  113.                                    ToRealPoint(12,13)],
  114.                                    ToLegend('Mar', colbrIndigo, 14.1,5));
  115.  
  116.   jGraphicsBuffer:= jBitmap1.GetByteBuffer(w,h);
  117.  
  118.   PGlobalDirectImagePixel:= jBitmap1.GetDirectBufferAddress(jGraphicsBuffer);
  119.  
  120.   FPNoGUIGraphicsBridge1.Surface.GetRGBAGraphics(PGlobalDirectImagePixel);
  121.  
  122.   jImageView1.SetImageBitmap(jBitmap1.GetBitmapFromByteBuffer(jGraphicsBuffer, w, h));
  123. end;
  124.  
  125. end.
  126.  


AppTFPNoGUIGraphicsBridgeDemo5  "unit1.pas" code  "look and feel" is here:
Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo5\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  10.     Laz_And_Controls_Events, AndroidWidget, FPNoGUIGraphicsBridge, ViewPort;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  18.     jBitmap1: jBitmap;
  19.     jButton1: jButton;
  20.     jImageView1: jImageView;
  21.     jPanel1: jPanel;
  22.     jPanel2: jPanel;
  23.     jTextView1: jTextView;
  24.     ViewPort1: TViewPort;
  25.     ViewPort2: TViewPort;
  26.     procedure jButton1Click(Sender: TObject);
  27.   private
  28.     {private declarations}
  29.   public
  30.     {public declarations}
  31.   end;
  32.  
  33. var
  34.   AndroidModule1: TAndroidModule1;
  35.   PGlobalDirectImagePixel: PJByte;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. uses
  42.   GeometryUtilsBridge, fpcolorbridge;
  43.  
  44. { TAndroidModule1 }
  45.  
  46. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  47. var
  48.   jGraphicsBuffer: jObject;
  49.   w, h: integer;
  50. begin
  51.   w:= jPanel2.Width;
  52.   h:= jPanel2.Height;
  53.  
  54.   ViewPort1.Height:= Trunc(h/2);
  55.   ViewPort1.Width:= w;
  56.   ViewPort1.SetScaleXY(0 {minx}, 23 {maxx}, 0 {miny}, 100 {maxy});
  57.  
  58.   ViewPort2.YTop:= Trunc(h/2);
  59.   ViewPort2.Height:= Trunc(h/2);
  60.   ViewPort2.Width:= w;
  61.   ViewPort2.SetScaleXY(0 {minx}, 2.5*6 {maxx = range*6}, 0 {miny}, 100 {maxy});
  62.  
  63.   FPNoGUIGraphicsBridge1.SetSurfaceSize(w,h);
  64.   FPNoGUIGraphicsBridge1.PathToFontFile:= '/system/fonts/Roboto-Regular.ttf'; //or DroidSerif-Bold.ttf
  65.  
  66.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  67.   FPNoGUIGraphicsBridge1.PaintViewPort;
  68.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  69.  
  70.   FPNoGUIGraphicsBridge1.DrawDataBars([ToBar(15,'Jan', colbrBlue),
  71.                                            ToBar(30,'Fev', colbrYellow),
  72.                                            ToBar(70,'Mar', colbrRed),
  73.                                            ToBar(25,'Abr', colbrLightBlue),
  74.                                            ToBar(40,'Mai', colbrLime),
  75.                                            ToBar(60,'Jun', colbrLightSalmon),
  76.                                            ToBar(15,'Jul', colbrGold),
  77.                                            ToBar(30,'Ago', colbrMagenta),
  78.                                            ToBar(70,'Set', colbrGreen),
  79.                                            ToBar(25,'Out', colbrLightSlateBlue),
  80.                                            ToBar(40,'Nov', colbrOrange),
  81.                                            ToBar(60,'Dez', colbrSalmon)]);
  82.  
  83.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort2;
  84.   FPNoGUIGraphicsBridge1.PaintViewPort;
  85.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  86.  
  87.   FPNoGUIGraphicsBridge1.DrawDataHistograms(
  88.                                               [ToHistogram(30, colbrGreen),
  89.                                               ToHistogram(45, colbrGold),
  90.                                               ToHistogram(65, colbrTomato),
  91.                                               ToHistogram(25, colbrLightSlateBlue),
  92.                                               ToHistogram(40, colbrRed),
  93.                                               ToHistogram(50, colbrBlue)],  2.5 {range});
  94.  
  95.  
  96.   jGraphicsBuffer:= jBitmap1.GetByteBuffer(w,h);
  97.  
  98.   PGlobalDirectImagePixel:= jBitmap1.GetDirectBufferAddress(jGraphicsBuffer);
  99.  
  100.   FPNoGUIGraphicsBridge1.Surface.GetRGBAGraphics(PGlobalDirectImagePixel);
  101.  
  102.   jImageView1.SetImageBitmap(jBitmap1.GetBitmapFromByteBuffer(jGraphicsBuffer, w, h));
  103. end;
  104.  
  105. end.
  106.  
Thanks to All!
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 12:26:10 am
Hello, I have a problem with installation.
From install_tutorial.txt
Code: [Select]
1. Configure Paths:
Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" -->  "Path Settings ..."
    -Path to Java JDK
              ex. C:\Program Files (x86)\Java\jdk1.7.0_21    {java win32}
        -Path to Android SDK
                  ex. C:\adt32\sdk
-Select Ndk version: [ex 10e]
      -Path to Ndk
          ex.  C:\adt32\ndk10e   
   
-Path to Java Resources  [Simonsayz's templates "*.java" and others: *.xml,  default Icons, etc...
     
  ex. C:\Laz4Android\components\LazAndroidWizard\java

I do not have a \Laz4Android\components\LazAndroidWizard\java folder

I have a \lazandroidmodulewizard-master\java folder which is the same as
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/java
but this not inside \Laz4Android\components

is this what it means?

My laz4android build is made from laz4android1.5-50093-FPC3.1.1.7z

thanks
Title: Re: Android Module Wizard
Post by: jmpessoa on December 24, 2015, 01:40:23 am
Ok... use  your  ".../java"  path ... no problem...
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 04:54:45 pm
I created an apk file using Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run"

It did not install, however I took file
D:\programming\laz4android\LamwGUIProject1\bin\LamwGUIProject1-debug.apk
manually copied to SD card, and install from phone file manager

The output from adb logcat is below, what was my mistake?

Code: [Select]
', referenced from method org.lamw.lamwguiproject1.Controls.jGLSurfaceView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 188 (Lorg/lamw/lamwguiproject1/jGLSurfaceView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jGridView', referenced from method org.lamw.lamwguiproject1.Controls.jGridView_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 189 (Lorg/lamw/lamwguiproject1/jGridView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jHorizontalScrollView', referenced from method org.lamw.lamwguiproject1.Controls.jHorizontalScrollView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 190 (Lorg/lamw/lamwguiproject1/jHorizontalScrollView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jHttpClient', referenced from method org.lamw.lamwguiproject1.Controls.jHttpClient_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 191 (Lorg/lamw/lamwguiproject1/jHttpClient;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jImageBtn', referenced from method org.lamw.lamwguiproject1.Controls.jImageBtn_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 192 (Lorg/lamw/lamwguiproject1/jImageBtn;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jImageFileManager', referenced from method org.lamw.lamwguiproject1.Controls.jImageFileManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 193 (Lorg/lamw/lamwguiproject1/jImageFileManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jIntentManager', referenced from method org.lamw.lamwguiproject1.Controls.jIntentManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 196 (Lorg/lamw/lamwguiproject1/jIntentManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jLocation', referenced from method org.lamw.lamwguiproject1.Controls.jLocation_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 202 (Lorg/lamw/lamwguiproject1/jLocation;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jMediaPlayer', referenced from method org.lamw.lamwguiproject1.Controls.jMediaPlayer_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 203 (Lorg/lamw/lamwguiproject1/jMediaPlayer;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jMenu', referenced from method org.lamw.lamwguiproject1.Controls.jMenu_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 204 (Lorg/lamw/lamwguiproject1/jMenu;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jMyHello', referenced from method org.lamw.lamwguiproject1.Controls.jMyHello_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 205 (Lorg/lamw/lamwguiproject1/jMyHello;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jNotificationManager', referenced from method org.lamw.lamwguiproject1.Controls.jNotificationManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 206 (Lorg/lamw/lamwguiproject1/jNotificationManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jPanel', referenced from method org.lamw.lamwguiproject1.Controls.jPanel_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 207 (Lorg/lamw/lamwguiproject1/jPanel;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jPreferences', referenced from method org.lamw.lamwguiproject1.Controls.jPreferences_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 208 (Lorg/lamw/lamwguiproject1/jPreferences;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jRatingBar', referenced from method org.lamw.lamwguiproject1.Controls.jRatingBar_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 212 (Lorg/lamw/lamwguiproject1/jRatingBar;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSeekBar', referenced from method org.lamw.lamwguiproject1.Controls.jSeekBar_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 214 (Lorg/lamw/lamwguiproject1/jSeekBar;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSensorManager', referenced from method org.lamw.lamwguiproject1.Controls.jSensorManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 215 (Lorg/lamw/lamwguiproject1/jSensorManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jShareFile', referenced from method org.lamw.lamwguiproject1.Controls.jShareFile_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 216 (Lorg/lamw/lamwguiproject1/jShareFile;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jShellCommand', referenced from method org.lamw.lamwguiproject1.Controls.jShellCommand_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 217 (Lorg/lamw/lamwguiproject1/jShellCommand;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSpinner', referenced from method org.lamw.lamwguiproject1.Controls.jSpinner_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 218 (Lorg/lamw/lamwguiproject1/jSpinner;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSqliteCursor', referenced from method org.lamw.lamwguiproject1.Controls.jSqliteCursor_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 219 (Lorg/lamw/lamwguiproject1/jSqliteCursor;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSqliteDataAccess', referenced from method org.lamw.lamwguiproject1.Controls.jSqliteDataAccess_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 220 (Lorg/lamw/lamwguiproject1/jSqliteDataAccess;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSurfaceView', referenced from method org.lamw.lamwguiproject1.Controls.jSurfaceView_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 221 (Lorg/lamw/lamwguiproject1/jSurfaceView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSwitchButton', referenced from method org.lamw.lamwguiproject1.Controls.jSwitchButton_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 222 (Lorg/lamw/lamwguiproject1/jSwitchButton;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jTCPSocketClient', referenced from method org.lamw.lamwguiproject1.Controls.jTCPSocketClient_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 223 (Lorg/lamw/lamwguiproject1/jTCPSocketClient;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jTextFileManager', referenced from method org.lamw.lamwguiproject1.Controls.jTextFileManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 224 (Lorg/lamw/lamwguiproject1/jTextFileManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jTimePickerDialog', referenced from method org.lamw.lamwguiproject1.Controls.jTimePickerDialog_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 227 (Lorg/lamw/lamwguiproject1/jTimePickerDialog;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jToggleButton', referenced from method org.lamw.lamwguiproject1.Controls.jToggleButton_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 230 (Lorg/lamw/lamwguiproject1/jToggleButton;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jViewFlipper', referenced from method org.lamw.lamwguiproject1.Controls.jViewFlipper_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 232 (Lorg/lamw/lamwguiproject1/jViewFlipper;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jView', referenced from method org.lamw.lamwguiproject1.Controls.jView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 231 (Lorg/lamw/lamwguiproject1/jView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jWebView', referenced from method org.lamw.lamwguiproject1.Controls.jWebView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 233 (Lorg/lamw/lamwguiproject1/jWebView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
D/dalvikvm( 7628): DexOpt: unable to opt direct call 0x0249 at 0x02 in Lorg/lamw/lamwguiproject1/Controls;.jActionBarTab_jCreate
D/dalvikvm( 7628): DexOpt: unable to opt direct call 0x024a at 0x02 in
.
.
.
.
.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 24, 2015, 05:03:04 pm

Hello dieselnutjob!

Please,

1.put here your "JNIAndroidProject.ini" from "Laz4android/config"

2. zip and put somewhere [open drive] your project, I will try some help....
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 05:16:03 pm
from C:\Develop\laz4android\config\JNIAndroidProject.ini
Code: [Select]
[NewProject]
PathToNdkPlataforms=C:\Develop\android\android-ndk-r10e
PathToJavaTemplates=C:\Develop\lazandroidmodulewizard-master\java
PathToJavaJDK=C:\Program Files (x86)\Java\jdk1.8.0_65
PathToAndroidNDK=C:\Develop\android\android-ndk-r10e
PathToAndroidSDK=C:\Develop\android\android-sdk-windows
PathToAntBin=C:\Develop\apache-ant-1.9.6-bin\apache-ant-1.9.6\bin
NDK=3
PrebuildOSYS=windows
PathToWorkspace=D:\programming\laz4android
FullProjectName=D:\programming\laz4android\LamwGUIProject1
InstructionSet=0
FPUSet=0
ProjectModel=1
AntPackageName=org.lamw
AndroidPlatform=0
MinApi=2
TargetApi=0
AntBuildMode=debug
MainActivity=App
SupportV4=no
Title: Re: Android Module Wizard
Post by: jmpessoa on December 24, 2015, 05:25:30 pm

Yes, config is OK!

Quote
I created an apk file using Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run"
It did not install....

1. just a reminder: your device was prepared for "debug/development" mode?

2. You do "build" before "[Lamw] Build Apk and Run" ?



Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 06:19:52 pm
1. just a reminder: your device was prepared for "debug/development" mode?
In developer options I have USB debugging="on". Is this what you mean?

2. You do "build" before "[Lamw] Build Apk and Run" ?
Yes.

I do not mind if the APK is automatically installed, or not.  I can install it myself.  The problem is that it crashes when run on the phone.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 24, 2015, 06:52:48 pm
Quote
...I do not mind if the APK is automatically installed..

Yes, if your device and system is properly configured ... it can be found? your device drive was installed?

Please, "zip" and put somewhere [open drive] your project, I will try some help....
Title: Re: Android Module Wizard
Post by: jmpessoa on December 24, 2015, 08:54:59 pm


Hello  dieselnutjob!

1. A first problem....  you do a small and deadly/fatal modification . Please, unchecked the "the pass option to linker with -k..."  and clear the Edit below...  Now you will get a correct ".so" [~ 575 k]


2. Check your "...\LamwGUIProject1\bin\classes\org\lamw\lamwguiproject1" folder ... the correct is 136 files


Note: the discussion about android 5.0 "pass option to linker with -k..."  Is not applicable to produce a Lamw  ".so"
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 09:33:22 pm
1. A first problem....  you do a small and deadly/fatal modification . Please, unchecked the "the pass option to linker with -k..."  and clear the Edit below...  Now you will get a correct ".so" [~ 575 k]

My .so file is 247k.
I have removed the pass linker with -k box, but it still will not run.

2. Check your "...\LamwGUIProject1\bin\classes\org\lamw\lamwguiproject1" folder ... the correct is 136 files

I have only 41 files.

How do I repair this?
Title: Re: Android Module Wizard
Post by: jmpessoa on December 24, 2015, 09:54:08 pm
Quote
...I have removed the pass linker with -k box, but it still will not run.

And cleanup the Edit below?  <<------------!!!

Quote
I have only 41 files. How do I repair this?

Delete the folder  "\bin" from "...LamwGUIProject1\bin\" 

and more: delete the Apk from device, too.

NOTE: what about a new "LamwGUIProject2"  attempt?  [the Wizard will take care of all configs for you!]
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 11:37:05 pm
this is my attempt at project2, there is a problem at picture 3

http://www.pscan.eu/dev/project2a.png (http://www.pscan.eu/dev/project2a.png)

http://www.pscan.eu/dev/project2b.png (http://www.pscan.eu/dev/project2b.png)

http://www.pscan.eu/dev/project2c.png (http://www.pscan.eu/dev/project2c.png)
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 24, 2015, 11:50:11 pm
I am trying something.

This time I have downloaded https://github.com/jmpessoa/lazandroidmodulewizard using tortoisesvn instead of the "download zip" function of the website.

The old folder had 4388 files
The new folder (done with SVN) has 6581 files !

I will re-install everything and try again
Title: Re: Android Module Wizard
Post by: jmpessoa on December 25, 2015, 12:02:45 am
Hi dieselnutjob!

Ok. Good Job!

But, I think your installation was correct! The master zip is OK!

What about use some "c:" folder and not "d:" folder for development....[just guessing
!]

The message box error is quite strange!
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 25, 2015, 12:44:20 am
project moved to c: drive and application is working on my 5.1.1 phone  :D

thank you!  and merry Christmas!
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 25, 2015, 12:53:56 am
and on a 4.4 phone, and on a 6.0.1 tablet  :D :D :D :D :D
Title: Re: Android Module Wizard
Post by: jmpessoa on December 25, 2015, 01:07:29 am

Congratulations!

Welcome to Lamw: Lazarus Android Module Wizard!

Merry Christmas!

Title: Re: Android Module Wizard
Post by: DelphiFreak on December 25, 2015, 08:11:12 am
Hello dieselnutjob,

I am the developer/maintainer of laztoapk.
You have spent now some time to get your problems solved and learned to use both tools. (laztoapk and lamw).
I have very limited sparetime and could not get into lamw so far. Could you shortly share your expirience now for other folks interested in doing android stuff with lazarus?

Would it make sense to merge lamw and laztoapk into one setup?

My intention for laztoapk was: Help people to get all this tool-chain stuff configured/setup correctly to let a user make his first app  without much pain !

Regards,
Sam
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 25, 2015, 08:57:56 am
There is one fundamental difference between the two approaches.

laztoapk sets up an environment which uses customdrawn
lamw uses something else, I have not figured out exactly what it is yet

at least that is my understanding

There are some problems with my installation.  When you create a new project it will crash at first, and you must restart lazarus to make it work.  However it makes working Android apps so it is still brilliant!

I think that the best thing would be for me to start again with a blank PC.  I will repeat what I have done, and write down exactly what I have done so that you can repeat it yourself easily.

If you can repeat my instructions, and then turn this into a program / script that does this automatically, which will be 90% the same as the existing laztoapk then I think that this will be something useful, especially for other newbies.

I need some help from you.
I have two files on my c: drive. They are sdk.zip and ndk.zip
I think that these files have been downloaded by laztoapk
can you tell me the url that laztoapk has used to download these files?

I think that you should replicate my setup (and I will help you to do this), and then I think that you should make your own decision whether to change laztoapk to support lamw instead of/as well as customdrawn.
Title: Re: Android Module Wizard
Post by: DelphiFreak on December 25, 2015, 10:27:14 am
Hello,

the answer to your question is here: http://sourceforge.net/p/laztoapk/svn/HEAD/tree/trunk/install/laztoapk.iss (http://sourceforge.net/p/laztoapk/svn/HEAD/tree/trunk/install/laztoapk.iss)

This is the innosetup-script that builds the setup.exe of laztoapk. Look at section _ISDownload. You will find there the url's for sdk and ndk.

Sam
Title: Re: Android Module Wizard
Post by: DelphiFreak on December 25, 2015, 10:38:24 am
Hi, one thing more ...

things are a little more complicated.....because laztoapk depends on laz4android.
I would prefer to have a laz4android package with pre-installed lamw.
Then I would adapt my laztoapk setup to contain a default/template-project for lamw.
As I can see the customdrawn-package is not really maintained/supported anymore.

I think this would be the best solution for everyone?

Sam
Title: Re: Android Module Wizard
Post by: jmpessoa on December 25, 2015, 04:19:50 pm

Hello DelphiFreak!

Quote
... because laztoapk depends on laz4android.

What about LazToApk as a "Lazarus" IDE new entrypoint/item  for  menu "Tools"?

Thank you!

Title: Re: Android Module Wizard
Post by: DelphiFreak on December 25, 2015, 07:12:32 pm
hi, yes an entry in tools menue called ”build&deploy app" would be nice. In fact laztoapk generates the batch-files to do this. so if you can give me a hint how to start windows batch from lazarus tools menue i will try to do it. sam
Title: Re: Android Module Wizard
Post by: dieselnutjob on December 25, 2015, 07:18:41 pm
okay people
check this out
http://www.pscan.eu/dev/lamw_howto.zip (http://www.pscan.eu/dev/lamw_howto.zip)

This is an openoffice / libreoffice doc which explain exactly how I got my install working on Windows 10 Home 64 bit.

Everthing is in one folder called C:\lamw
Title: Re: Android Module Wizard
Post by: jmpessoa on December 25, 2015, 09:00:01 pm
Hello, @DelphiFreak!

Here [Attachment] is a draft "laztoapk" package to add IDE menu entry point! 
Could serve as a kick start for your work!


Hello, @dieselnutjob!

I put  the "HOW_TO_INSTALL_by_Dieselnutjob.pdf" in Lamw github!

Thanks to All!

Title: Re: Android Module Wizard
Post by: dieselnutjob on December 25, 2015, 09:12:36 pm
i found that with sdk version 15 that it will build the .so file but it will not create the apk file. When I changed to sdk 17 it started to work. Hopefully none of my customers have devices older than jellybean
Title: Re: Android Module Wizard
Post by: jmpessoa on December 25, 2015, 09:26:10 pm
Go to [your]

"C:\Develop\android\android-sdk-windows\platforms"

What you found? [the platforms that your system can generate the apk!]
Title: Re: Android Module Wizard
Post by: DelphiFreak on December 25, 2015, 09:49:03 pm
Hello  jmpessoa,

thanks for your answer. I will try this out but it will take a while because I go for holiday's tomorrow.

@dieselnutjob: I had a look at your instruction document.  I think page1-8 is covered by laztoapk setup & pdf :
http://sourceforge.net/projects/laztoapk/files/Lazarus%20and%20Android.pdf/download (http://sourceforge.net/projects/laztoapk/files/Lazarus%20and%20Android.pdf/download)

So if we could motivate the creator of the laz4android package to include lamw by default, then I could remove "customdrawn" from my instruction manual and
add the last three pages from dieselnutjob to my manual.
And of course I would try to add the already discussed "build&deploy app" to tools menu of lazarus.

Sam

Title: Re: Android Module Wizard
Post by: jmpessoa on December 26, 2015, 07:27:24 pm
Hello All!

There is an updated Lamw Revision!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 38 - 26 December 2015 -

NEW! jRadioGroup component
NEW! jRatingBar component

NEW! AppRadioGroupDemo1
NEW! AppRatingBar Demo1   

Thanks and Happy 2016 to All!
 
Title: Re: Android Module Wizard
Post by: jmpessoa on December 31, 2015, 04:12:12 pm
Hello All!

There is an updated revision of "Lamw: Lazarus Android Wizard"

NEW! Added support to produce native executable console application.

NEW! LamwConsoleAppDemo1  [../demos/Console]

please, read:

        "readme_How_To_Run_AVD_Emulator.txt"
        "readme_How_To_Run_Real_Device.txt"     

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

thanks to All!
special tanks to @engkin and @gtyhn!

PS.

Here is the "unit1.pas"code  "look and feel":

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\LamwConsoleAppDemo1}
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils;
  10.  
  11. type
  12.  
  13.   { TAndroidConsoleDataForm1 }
  14.  
  15.   TAndroidConsoleDataForm1 = class(TDataModule)
  16.     procedure DataModuleCreate(Sender: TObject);
  17.   private
  18.     {private declarations}
  19.   public
  20.     {public declarations}
  21.   end;
  22.  
  23. var
  24.   AndroidConsoleDataForm1: TAndroidConsoleDataForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TAndroidConsoleDataForm1 }
  31.  
  32. procedure TAndroidConsoleDataForm1.DataModuleCreate(Sender: TObject);
  33. begin
  34.   writeln('Hello Lamw''s World!');
  35. end;
  36.  
  37. end.
  38.  

and here is the "lamwconsoleappdemo1.lpr"code  "look and feel":
Code: Pascal  [Select][+][-]
  1. {hint: save all files to location: C:\adt32\eclipse\workspace\LamwConsoleAppDemo1\ }
  2. program lamwconsoleappdemo1;  //[by Lamw: Lazarus Android Module Wizard: 12/30/2015 23:22:38]
  3.  
  4. {$mode delphi}
  5.  
  6. uses
  7.   Classes, SysUtils, CustApp, unit1;
  8.  
  9. type
  10.  
  11.   TAndroidConsoleApp = class(TCustomApplication)
  12.   public
  13.       procedure CreateForm(InstanceClass: TComponentClass; out Reference);
  14.       constructor Create(TheOwner: TComponent); override;
  15.       destructor Destroy; override;
  16.   end;
  17.  
  18. procedure TAndroidConsoleApp.CreateForm(InstanceClass: TComponentClass; out
  19.   Reference);
  20. var
  21.   Instance: TComponent;
  22. begin
  23.   Instance := TComponent(InstanceClass.NewInstance);
  24.   TComponent(Reference):= Instance;
  25.   Instance.Create(Self);
  26. end;
  27.  
  28. constructor TAndroidConsoleApp.Create(TheOwner: TComponent);
  29. begin
  30.   inherited Create(TheOwner);
  31.   StopOnException:=True;
  32. end;
  33.  
  34. destructor TAndroidConsoleApp.Destroy;
  35. begin
  36.   inherited Destroy;
  37. end;
  38.  
  39. var
  40.   AndroidConsoleApp: TAndroidConsoleApp;
  41.  
  42. begin
  43.   AndroidConsoleApp:= TAndroidConsoleApp.Create(nil);
  44.   AndroidConsoleApp.Title:= 'Android Executable Console App';
  45.   AndroidConsoleApp.Initialize;
  46.   AndroidConsoleApp.CreateForm(TAndroidConsoleDataForm1, AndroidConsoleDataForm1);
  47. end.
  48.  
Title: Re: Android Module Wizard
Post by: xinyiman on January 07, 2016, 03:48:45 pm
Hello guys, how do I get rid of the keyboard when I leave a editbox?

Thanks so much
Title: Re: Android Module Wizard
Post by: jmpessoa on January 07, 2016, 04:10:49 pm
Try HAndle OnEnter Event [go, done, next, etc]

procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
   jEditText1.SetImeOptions(imeActionDone);
end;


And you can try:    [from demo "AppEditTextDemo1"]

procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
  //jEditText1.DispatchOnChangeEvent(False);   //the trick!  stop event [improve performace]!
  //jEditText1.DispatchOnChangedEvent(False);   //the trick! stop event [improve performace]!
  jEditText1.SetImeOptions(imeFlagNoFullScreen);
                                                   //IMEs will never go into full screen mode,
                                                   //and always leave some space to display the application UI

  jTextView1.TextTypeFace:= tfBold;
  jTextView1.CustomColor:= $FF2C2F3E;   
  jTextView1.FontColor:= colbrCustom;
end;

Title: Re: Android Module Wizard
Post by: jmpessoa on January 07, 2016, 04:22:29 pm
Hello All!

GitHub Updated!

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 38.2 - 06 January 2016 -

   IMPROVEMENT! Better support for device screen rotation!  [Attachment]

   CHANGED! Changed OnRotate event signature  [sorry...]  //@Euller and @Leledumbo suggestion ...

   NEW! AppTFPNoGUIGraphicsBridgeDemo6  [ref. https://github.com/jmpessoa/tfpnoguigraphicsbridge]

      Projectile Motion Graphicis Demo [parameterized function] and device screen rotation!

      Screenshots Ref:

      https://app.box.com/s/h5r79o7dotgh0ke2dbhk1ltq04sswikd       //form in design time
      https://app.box.com/s/kpeuxb8p33m6rkg42bg1d0g2p2i7pkhd   //started app
      https://app.box.com/s/l2ncravxk1mvlahvoyoup4lxyk0sh2ro         //simple rotate control

      https://app.box.com/s/2e6xpm0wwhaus0xdw7x7ufc08atlewh4    //[checked] smart rotate control!

      Please, read the "readme.txt" in project folder "../jni" 

Thanks to All!
Title: Re: Android Module Wizard
Post by: xinyiman on January 07, 2016, 06:39:26 pm
My code


procedure TAndroidModule2.Txt_SviluppoEnter(Sender: TObject);
begin
     Txt_Sviluppo.SetImeOptions(imeActionDone);
end;

and

procedure TAndroidModule2.AndroidModule2JNIPrompt(Sender: TObject);
begin
     Txt_Sviluppo.SetImeOptions(imeFlagNoFullScreen);
end;

But not work.
For example, they are set to Txt_Sviluppo and I click the button btn_calcola. The keyboard that opened when I entered the Txt_Sviluppo remains open. I want to close. How can I do?

I would also like to know how to handle exceptions.Because if use


     try
        try
           
           //nostro codice da eseguire su cui vogliamo effettuare una gestione degli errori
           ...
           
        finally
               //codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione               
       end;
     except
           on E: Exception do
           begin
             
              //codice da eseguire solo se si verifica un eccezzione
             
           end;
     end;


 it does not work use. Thanks so much



Try HAndle OnEnter Event [go, done, next, etc]

procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
   jEditText1.SetImeOptions(imeActionDone);
end;


And you can try:    [from demo "AppEditTextDemo1"]

procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
  //jEditText1.DispatchOnChangeEvent(False);   //the trick!  stop event [improve performace]!
  //jEditText1.DispatchOnChangedEvent(False);   //the trick! stop event [improve performace]!
  jEditText1.SetImeOptions(imeFlagNoFullScreen);
                                                   //IMEs will never go into full screen mode,
                                                   //and always leave some space to display the application UI

  jTextView1.TextTypeFace:= tfBold;
  jTextView1.CustomColor:= $FF2C2F3E;   
  jTextView1.FontColor:= colbrCustom;
end;
Title: Re: Android Module Wizard
Post by: jmpessoa on January 07, 2016, 07:07:27 pm

About ExceptionHandler:

there is a demo:   AppPascalLibExceptionHandlerDemo1

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. var
  3.   i: integer;
  4. begin
  5.   try
  6.     // some erroneous code
  7.     i:= StrToInt('p');
  8.   except
  9.     on E: Exception do ShowMessage(Self.DumpExceptionCallStack(E));  //Thanks to Euller and Oswaldo!
  10.   end;
  11. end;
  12.  
  13.  
Title: Re: Android Module Wizard
Post by: jmpessoa on January 08, 2016, 12:02:16 am
@ xinyiman

Quote
.. I click the button btn_calcola.The keyboard that opened when I entered the Txt_Sviluppo remains open. I want to close. How can I do?

jEditText has "immHide" [and "immShow"]  methods ....

Please, try   

Code: Pascal  [Select][+][-]
  1.   Txt_Sviluppo.immHide
  2.  

[maybe] in btn_calcola OnClick event handle  ...


PS. NEW!

Version 0.6 - rev. 38.3 - 07 January 2016 -

   NEW! Added jForm method  "ToggleSoftInput" 
            to  Show/Hide Soft Keyboard ...

Title: Re: Android Module Wizard
Post by: Mladen on March 07, 2016, 02:52:40 pm
Hello i was wondering is there any way make jListView have multiple columns . So it can be something like DBGrid in Lazarus ? Or maybe there is some other way to achieve this?  :)

And is there a way to make text inside jEditText becomes selected on certain event.

Thank you for all your hard work !

Cheers!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 07, 2016, 08:10:09 pm

Hello Mladen!

1. You can try jGridView. There is a demo: "AppGridViewDemo1"

2. About jEditTex, I will do some test and try some solution...

Thank you!
Title: Re: Android Module Wizard
Post by: Mladen on March 09, 2016, 08:26:20 am
Well yes, but as I can see it jGridView is similar to jListView, its just arranged differently and its still one dimensional (maybe I am wrong!). I was thinking if there is some way where you can for example get or write data to  Row[3].Column[1] or something like that  :)

Thank you for your effort!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 24, 2016, 07:00:40 am

Lamw Updated!

Version 0.6 - rev. 38.4 - 24 March 2016 -

   NEW! Added jEditText methods: 
         SetSelectAllOnFocus   // <<---@Mladen suggestion
         SelectAll      // <<---@Mladen suggestion

   NEW! Tools --> [Lamw] Android Module Wizard --> Build FPC Cross Android

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Quote
And is there a way to make text inside jEditText becomes selected on certain event.

Yes! Please try:

Code: Pascal  [Select][+][-]
  1.   jEditText1.SetSelectAllOnFocus(True);  
  2.   jEditText1.SetFocus;    
  3.  
  or
Code: Pascal  [Select][+][-]
  1. jEditText1.SelectAll();
  2.  

Thanks to All!
Title: Re: Android Module Wizard
Post by: Mladen on March 25, 2016, 02:03:07 pm


   NEW! Added jEditText methods: 
         SetSelectAllOnFocus   // <<---@Mladen suggestion
         SelectAll      // <<---@Mladen suggestion

   

I have just tested it and its working great! :D Thank you so much!!
Title: Re: Android Module Wizard
Post by: Mladen on March 25, 2016, 02:20:37 pm
I am sorry for bothering . I am building a business application for  android device with integrated laser barcode scanner. The device has more physical buttons then standard android smartphone.

So I was wandering is there a way to trigger onKeyPress event just like on Lazarus TForm component. I need it so I can turn on its laser by pressing certian physical button which sends keycode (#131 or some other).

On standard TForm I could do for example 
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
  2. begin
  3.  if Key=#131 then
  4.  TurnOnScanner;
  5. end;
  6.  

Thank you!!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 25, 2016, 05:16:40 pm

There is  "OnEnter" event  to handle: go, done, next, ... keys

procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
      TurnOnScanner;
end;
Title: Re: Android Module Wizard
Post by: Mladen on March 26, 2016, 03:18:42 pm

There is  "OnEnter" event  to handle: go, done, next, ... keys

procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
      TurnOnScanner;
end;

Thank you very much, that also helped me!
Title: Re: Android Module Wizard
Post by: developing on March 28, 2016, 09:42:37 pm
Hi all

1-How can I disable screen rotation on Android device? (In programming with LAMW)
2-How can set alignment for text controls like jEdit to right? For right to left language like Hebrew and Arabic?
Title: Re: Android Module Wizard
Post by: jmpessoa on March 28, 2016, 10:30:52 pm
Hello Developing!


1.
Quote
How can I disable screen rotation on Android device? (In programming with LAMW)

Please, try handle "OnJNIPrompt" and  "OnRotate"  events, example:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject; rotate: TScreenStyle);
  2. begin
  3.        Self.SetScreenOrientationStyle(ssPortrait);     //force Portrait...
  4. end;
  5.  

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1Rotate(Sender: TObject; rotate: TScreenStyle);
  2. begin
  3.    if rotate = ssLandscape then   // device is on horizontal...
  4.           Self.SetScreenOrientationStyle(ssPortrait);     //force Portrait...
  5. end;
  6.  

Quote
2-How can set alignment for text controls like jEdit to right? For right to left language like Hebrew and Arabic?

I will study this issue and try to help ...

Thank you!
Title: Re: Android Module Wizard
Post by: Mladen on March 30, 2016, 02:52:07 pm
Hello, I was wondering is there any way to prevent jDialogProgress from being closed by user . :)
Title: Re: Android Module Wizard
Post by: jmpessoa on April 01, 2016, 06:20:32 pm
Hello Mladen!

Please, try:

Code: Pascal  [Select][+][-]
  1.   jDialogProgress1.SetCancelable(False);
  2.   jDialogProgress1.Show();
  3.  
Title: Re: Android Module Wizard
Post by: Mladen on April 02, 2016, 12:30:05 pm
Hello Mladen!

Please, try:

Code: Pascal  [Select][+][-]
  1.   jDialogProgress1.SetCancelable(False);
  2.   jDialogProgress1.Show();
  3.  

Hello, thank you for your response !
I have tried what you said but unfortunately jDialogProgress1 still closes when user touches anywhere on the screen(except jDialogProgress1itself) or presses back key.

Cheers!
Title: Re: Android Module Wizard
Post by: jmpessoa on April 02, 2016, 04:04:01 pm

Sorry... I will try fix it!!

Thank you!


Edited: Done!!!  [Please, update "Controls.java" template]
Title: Re: Android Module Wizard
Post by: Mladen on April 03, 2016, 12:26:32 am
It works now! 

Thank you so much !!!
Title: Re: Android Module Wizard
Post by: developing on April 04, 2016, 03:19:43 pm
Hi jmpessoa

I want create some component in run-time but some of property don't work or wrong result.

For example when I put three jEdittext on form and set width, height and fontsize it's pretty work, but when create these component programmatically, some property wrong, look at the below code:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. var
  3.   Cells: array [1..3] of jEditText;
  4. begin
  5. for I := Low(Cells) to High(Cells) -6  do    
  6. begin
  7.   Cells[i] := jEditText.Create(Self);// It's work
  8.   Cells[i].Parent := jPanel1;// It's work
  9.   Cells[i].Name := 'Cell' + IntToStr(i) + IntToStr(j);// It's work
  10.   Cells[i].Text := '';// It's work
  11.   Cells[i].Height := Ord(lpOneFifthOfParent);// Don't work
  12.   Cells[i].Width := Ord(lpOneThirdOfParent);// Don't work
  13.   Cells[i].FontSize := 12;// Don't work
  14.   Cells[i].Left := i * (Cells[i, j].Height + Space) - 20; // It's work but wrong
  15.   Cells[i].Top := j * (Cells[i, j].Width + Space) - 20; // It's work but wrong
  16.   Cells[i].Alignment := taRight;// It's work
  17. end;

Please help me.
Title: Re: Android Module Wizard
Post by: molly on April 04, 2016, 04:23:24 pm
@developing:
Hmz, not wanting to sidetrack too much, as this is not really my kind of topic.

But, do you have some kind of magical height vs width distance formula that makes it plausible to use:
Quote
Cells.Left := i * (Cells[i, j].Height + Space) - 20; // It's work but wrong
Cells.Top := j * (Cells[i, j].Width + Space) - 20; // It's work but wrong

Instead of (which is more commonly seen):
Quote
Cells.Top := i * (Cells[i, j].Height + Space) - 20; // It's work but wrong
Cells.Left := j * (Cells[i, j].Width + Space) - 20; // It's work but wrong

As Top and Height properties are related to each other, just as property Left and Width are.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 04, 2016, 05:01:17 pm
Hello @developing!  [Edited!]


1. About height and width: Its makes little sense in run time [each device has its own measures...]

2. [Molly] No. I dont have a "magical" height vs width distance formula....

Please, use:

    LayoutParamWidth =  ....
    LayoutParamHeight = .....

and

    PosRelativeToAnchor = ....
    PosRelativeToParent =  ....

Thanks!

Edited: Ok Molly. Thank you for your help!
Title: Re: Android Module Wizard
Post by: molly on April 04, 2016, 05:26:09 pm
@jmpessoa:
Oops, sorry.  :-[ my post was meant @user developing.

I have modified my post to reflect this situation better.

Nevertheless, i thank you very much for your answer. Your comments as described is what i was more or less expecting (at least i thought that to be the case).

Hopefully, user developing will be able to take advantage of that :)
Title: Re: Android Module Wizard
Post by: jmpessoa on April 04, 2016, 05:40:18 pm
Hello Molly!

Thank you for your help! [ my apologies!  O:-)]
Title: Re: Android Module Wizard
Post by: developing on April 05, 2016, 04:17:47 pm
Hello jmpessoa

I read your help and use LayoutParam... and PosRelative... in button click event.

On my cell phone don't display anything.


Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. const
  3.   Rows = 3;
  4.   Cols = Rows;
  5. var
  6.   I, j: Integer;
  7.   Cells: Array [1..Rows,1..Cols]of jEditText;
  8. begin
  9.   for I := Low(Cells) to High(Cells)  do
  10.     for j := Low(Cells) to High(Cells)  do
  11.     begin
  12.       Cells[i,j] := jEditText.Create(Self);
  13.       Cells[i,j].Visible:=True;
  14.       Cells[i,j].Enabled:=True;
  15.       Cells[i,j].Parent := jPanel1;
  16.       Cells[i,j].Name := 'Cell' + IntToStr(i) + IntToStr(j);
  17.       Cells[i,j].LayoutParamHeight := lp96px;
  18.       Cells[i,j].LayoutParamWidth := lpOneThirdOfParent;
  19.           // set anchor for each cells
  20.       if i = 1 then
  21.       begin
  22.         if j > 1 then
  23.           Cells[i, j].Anchor:=Cells[i,j - 1];
  24.       end
  25.       else
  26.       begin
  27.         if j = 1 then
  28.           Cells[i, j].Anchor:=Cells[i - 1,1]
  29.         else
  30.           Cells[i, j].Anchor:=Cells[i - 1,j - 1];
  31.       end;
  32.           // positioning for cells
  33.       if i = 1 then
  34.         Cells[i,j].PosRelativeToParent:=[rpTop]
  35.       else
  36.         Cells[i,j].PosRelativeToAnchor:=[raToRightOf];
  37.       if j = 1 then
  38.       begin
  39.         Cells[i,j].PosRelativeToParent := [rpLeft];
  40.         if i > 1 then
  41.           Cells[i, j].PosRelativeToAnchor:=Cells[i, j].PosRelativeToAnchor + [raBelow];
  42.       end
  43.       else
  44.         Cells[i, j].PosRelativeToAnchor:=Cells[i, j].PosRelativeToAnchor+[raBelow];
  45.       Cells[i, j].Text:='cells'+IntToStr(i)+','+IntToStr(j);
  46.     end;
  47. end;

Even create simple component.

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton8Click(Sender: TObject);
  2. var
  3.   jEditTemp: jEditText;
  4.   jButtonTemp: jButton;
  5. begin
  6.   jEditTemp := jEditText.Create(Self);
  7.   jEditTemp.Parent := jPanel1;
  8.   jEditTemp.Text:='test';
  9.   jEditTemp.LayoutParamWidth:=lpMatchParent;
  10.   jEditTemp.LayoutParamHeight:=lpWrapContent;
  11.   jEditTemp.FontSize:=18;
  12.   jEditTemp.PosRelativeToParent:=[rpBottom, rpLeft];
  13.  
  14.   jButtonTemp := jButton.Create(Self);
  15.   jButtonTemp.Parent:=jPanel1;
  16.   jButtonTemp.Text:='press me';
  17.   jButtonTemp.LayoutParamWidth:=lpMatchParent;
  18.   jButtonTemp.LayoutParamHeight:=lpWrapContent;
  19.   jButtonTemp.Anchor:=jEditTemp;
  20.   jButtonTemp.PosRelativeToAnchor:=[raAbove];
  21. end;

In previous method (Previous post) components created but wrong property, and with these methods don't display anything.

Please test it.

And ohter question: How can access to sdcard and file that saved on sdcard? And how display content of file on sdcard?(For example show text file content)
Title: Re: Android Module Wizard
Post by: jmpessoa on April 05, 2016, 06:39:23 pm

Hello  developing!

Here is a litle example code:

Code: Pascal  [Select][+][-]
  1.   jEditTemp := jEditText.Create(Self);
  2.   jEditTemp.LayoutParamWidth:=lpMatchParent;
  3.   jEditTemp.PosRelativeToParent:=[rpCenterInParent];
  4.   jEditTemp.Init(gApp);   // <<---- you need Init the control !!!!
  5.  
  6.  //use jTextFileManager component to load text file from sdcard or from assets
  7.   ShowMessage(jTextFileManager1.LoadFromSdCard('myFile.txt'));
  8.  

Thank you!
Title: Re: Android Module Wizard
Post by: rodrigogs2 on April 07, 2016, 04:13:11 pm
Hello jmpessoa!

Where can I find the documentation for android developing on lazarus using your AndroidModuleWizard ?

Title: Re: Android Module Wizard
Post by: jmpessoa on April 07, 2016, 04:53:56 pm

Hello Rodrigo!

Please,  go to

https://github.com/jmpessoa/lazandroidmodulewizard

and try: "readme_get_start.txt"

Thank you!

PS. Anything, I'm here .... I can try help you....
Title: Re: Android Module Wizard
Post by: Mladen on April 12, 2016, 10:20:49 am
Hello I have noticed that when I set for an example
Code: Pascal  [Select][+][-]
  1. jEditText1.HintTextColor:=colbrSilver;
hint color always remain the default one.

Also when I set
Code: Pascal  [Select][+][-]
  1. jEditText1.InputTypeEx:=itxTextPassword;
first typed letter is not hidden :)  Only when entering the 2nd one the first one gets hidden.

Also I was wondering is there a way to to set FontFace for jListView. For an example on jEditText i can do
Code: Pascal  [Select][+][-]
  1. jEditText1.FontFace:=FFMonospace;

Thank you!!
Title: Re: Android Module Wizard
Post by: Ñuño_Martínez on April 12, 2016, 05:42:32 pm
I've re-read again a few the way this wizard works, and I still wondering why it is so complicate to create Android applications.  It has no sense for me.  %)

And don't tell me about cross-compiling:  it isn't.

Anyway, keep up the work.  I'll need to use this soon.  ;D
Title: Re: Android Module Wizard
Post by: jmpessoa on April 13, 2016, 03:44:39 am
Hello All!

The LAMW was updated!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 38.6 - 12 April 2016 -

   UPDATED! jHttpClient has been updated to use HttpURLConnection [We can Target API >= 21 !!] // <<-----Thanks to @Renabor!

   NEW! Added demo AppHttpClientDemo2

   NEW! jListView property "FontFace" // <<---@Mladen suggestion



@Mladen.....

1. [FIXED!] colbrSilver = colbrDefault !!!

2. About password mask: I will try some solution!

3 [SOLVED!]  jListView.FontFace:= ffMonospace ;


@Ñuño_Martínez....

Please try: "readme_get_start.txt" ...


Thanks to All!
Title: Re: Android Module Wizard
Post by: Mladen on April 13, 2016, 11:46:33 am
Hello and thank you for your time!

I have tested it and confirm that setting
Code: Pascal  [Select][+][-]
  1.  jEditText1.HintTextColor
now works but only when
Code: Pascal  [Select][+][-]
  1. jEditText1.FontColor=colbrDefault

I have also tried
Code: Pascal  [Select][+][-]
  1.  jListView1.FontFace:=FFMonospace
but it doesn't appear to work for me.


Thank you!!
Title: Re: Android Module Wizard
Post by: jmpessoa on April 13, 2016, 10:37:49 pm
Hello Mladen!

Sorry....

I make a minor change to try fix  jListView1.FontFace

ref. https://github.com/jmpessoa/lazandroidmodulewizard

[changed]
"Controls.java"
"Laz_And_Controls.pas"

NOTE: If you have put [initial] items in design time,
then you need set jListView1.FontFace in design time, too.
Title: Re: Android Module Wizard
Post by: Mladen on April 14, 2016, 12:12:48 pm
Hello Mladen!

Sorry....

I make a minor change to try fix  jListView1.FontFace

ref. https://github.com/jmpessoa/lazandroidmodulewizard

[changed]
"Controls.java"
"Laz_And_Controls.pas"

NOTE: If you have put [initial] items in design time,
then you need set jListView1.FontFace in design time, too.

I tried jListView1.FontFace:=FFMonospace;

And it works now!

Thank you!!
Title: Re: Android Module Wizard
Post by: Handoko on April 16, 2016, 04:52:17 am
I can't make OpenGL (jCanvasES2) work on LAMW. Has anybody had any success to use OpenGL on LAMW?

My sample code:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jCanvasES2_1GLCreate(Sender: TObject);
  2. begin
  3.   jCanvasES2_1.Screen_Setup(1, 1);
  4. end;
  5. ...
  6. ...
  7. procedure TAndroidModule1.jCanvasES2_1GLDraw(Sender: TObject);
  8. var
  9.   XY: TXY;
  10.   RGBA: TRGBA;
  11. begin
  12.  
  13.   jCanvasES2_1.Screen_Clear(0.9, 0.3, 0.3, 1);
  14.  
  15.   XY.X := Random(100)/100;
  16.   XY.Y := Random(100)/100;
  17.   RGBA.R := Random(100)/100;
  18.   RGBA.G := Random(100)/100;
  19.   RGBA.B := Random(100)/100;
  20.   RGBA.A := Random(100)/100;
  21.  
  22.   jCanvasES2_1.DrawCircle(XY, 0, Random(100)/100+0.05, RGBA);
  23.  
  24. end;

Is there anything wrong with the code above? I noticed that eglSwapBuffers isn't available on LAWM.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 16, 2016, 06:05:25 am

Hello Handoko!

Please, try  "AppDemo1"....

Thanks you!   
Title: Re: Android Module Wizard
Post by: Handoko on April 16, 2016, 08:05:18 am
Did you mean this one?
.../Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1

I can't see any OpenGL ES usage in the demo. Also it can't be compiled on my computer. Please see the attached picture for the error messages.

If I start a new Android [GUI] Module [lamw] and put some buttons, it works. I can build apk and run on my Intel-based Android phone (although the configuration is Android-arm).
Title: Re: Android Module Wizard
Post by: Leledumbo on April 16, 2016, 09:32:28 am
Did you mean this one?
.../Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1
No, the one under Eclipse folder. You can make it an Ant project simply by providing build.xml that you can copy from the Ant demos project and modify the values inside accordingly.
I can build apk and run on my Intel-based Android phone (although the configuration is Android-arm).
Intel based Android devices usually have libhoudini installed. It's an ARM compatibility layer so Intel based devices can still install and run many applications from play store which might be compiled only for ARM.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 16, 2016, 03:56:55 pm
Some info:

about "build.xml"  it is already there...   [folder "... /jni" ]

But to use/test any demo App you will need:

1. configure "build.xml"  to match your system...

2. configure the ".lpi" to match your system...

NOTE 1: if you need configure for "x86" please, go to folder "...\AppDemo1\jni\build-modes"  and see "readme.txt" to replace some lines in ".lpi"

NOTE 2. The LAMW produce many ".bat" or ".sh" to logcat ... there are more in  "...\utils", too

3. Lazarus IDE --> Run --> "build"   [to produce the pascal jni ".so"]

4. Connect your Device-PC  via usb ...

5. Lazarus IDE --> Run --> "[Lamw] Build Android Apk and Run"

NOTE:  All projects in "Eclipse" folder are Ant compatible .... and can be used as explained....

Thanks All!

PS. HttpClient [updated!] now work fine when target API >=21
Title: Re: Android Module Wizard
Post by: Handoko on April 16, 2016, 04:19:26 pm
Thanks Leledumbo and jmpessoa for the helps.

So far I now can compile simple tests (new project with some texts and buttons) and able to build apks that can run on my Intel phone without changing any of the default project options generated by the LAMW.

But I have problem compiling the the AppAntDemo1. When I tried to compile it, I get this message:
Quote
/usr/bin/arm-linux-androideabi-ld: cannot find -ljnigraphics
/usr/bin/arm-linux-androideabi-ld: cannot find -lGLESv1_CM
/usr/bin/arm-linux-androideabi-ld: cannot find -lGLESv2
/usr/bin/arm-linux-androideabi-ld: cannot find -lc
/usr/bin/arm-linux-androideabi-ld: cannot find -lc
/home/handoko/Android/lazandroidmodulewizard.git/trunk/demos/Eclipse/AppDemo1/jni/controls.lpr(1223,15) Error: (9013) Error while linking
/home/handoko/Android/lazandroidmodulewizard.git/trunk/demos/Eclipse/AppDemo1/jni/controls.lpr(1223,15) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode

Note:
My computer is Intel Core2 Quad + Ubuntu Mate 64-bit .
My target device is Intel 64-bit + Android 5.0
I ever tried LazToApk but no luck to make it work on Intel + Android 5.0
Title: Re: Android Module Wizard
Post by: Leledumbo on April 16, 2016, 04:31:25 pm
But I have problem compiling the the AppAntDemo1. When I tried to compile it, I get this message:
Modify path related project settings according to your installation, those libraries should be in $(your android ndk folder)/platforms/android-$(your target api)/arch-arm/usr/lib/.
Title: Re: Android Module Wizard
Post by: Handoko on April 17, 2016, 03:49:45 pm
Hello, I'm back. I'm new in using LAMW and my only Android device is Intel 64-bit. After a full day of testing, here I want to share what I found. Hope it can be useful.

The demos under the Eclipse folder aren't compatible with Intel 64-bit using libhoudini. I opened many of the demos (under Eclipse) and followed jmpessoa instructions properly modifying build.xml and .lpi files based on my successfully new generated app settings (which run properly on my device). All of them can be compiled without error but when running on my device, it said "Unfortunately, [name] has stopped."

Even if I removed all the components on the main form and deleted all the other forms in the demos, I still get same the result. The remain is very basic TAndroidModule jForm class only without any components nor events. Simply to say, it's only a blank app. So it makes me think, there could be something generated by LAMW that causes incompatible with Intel+libhoudini. Because if I started a new app using LAMW, the apk works on my device. I mean, the demos were generated using prior version of LAMW than mine (version 0.6). Can anybody tell me, is there a way we can refresh the files generated by LAMW but keep the 'pure' Lazarus code unchanged?

libhoudini compatibility layer is not 100% compatible with ARM. So far I have tested jTextView, jButton, jImageView, jImageList and jTimer. All of them work correctly on Intel device although my compiler was set to Android-arm. But if the command jCanvasES2.Texture_Load_All is being executed, an error will occur immediately.

All the tests above were compiled using Android-arm setting, because I still have no luck building my Lazaurs to cross compile to Android-i386. When try to compile to Android-i386, I got this error message: "Fatal: Cannot find system used by fcllaz of package FCL." Any idea what should I do?
Title: Re: Android Module Wizard
Post by: jmpessoa on April 17, 2016, 05:36:07 pm
Quote
Can anybody tell me, is there a way we can refresh the files generated by LAMW but keep the 'pure' Lazarus code unchanged?

Yes [in fact all demos should be upgraded before use] !!
Please, go to Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" --->> "Upgrade code templates"

Quote
...because I still have no luck building my Lazaurs to cross compile to Android-i386.

Please, [try]  Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" --->> "Build FPC Cross Android"

Thank you!

PS. It is always good to keep updated your LAMW version/revision
Title: Re: Android Module Wizard
Post by: Handoko on April 18, 2016, 03:03:15 pm
 :D It works.

But I'm still busy have no time to test the cross compiling feature. One thing I'm sure is there is texture problem when running arm-built app on Intel device. I'll found out more and report back.

Thank you.
Title: Re: Android Module Wizard
Post by: Handoko on April 21, 2016, 02:06:13 pm
Can anyone tell me that Build FPC Cross Android really works correcly on Linux 64-bit? Or I did it wrong?

This is my setting for running [Lamw] FPC Android Cross Compiler Builder:
Quote
FPC Source:
/home/handoko/Android/fpc

Path to Android NDK:
/home/handoko/Android/android-ndk-r11c

Path to FPC "make.exe":
/usr/bin

Architecture:
x86

After I clicked the Build button, an error popup and say:
"Cannot Run Extern [make] Tool!"

These are the information on the Messages window:
Quote
make[2]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2869: recipe for target 'build-stamp.i386-android' failed
make[1]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2935: recipe for target 'crossall' failed
Panic: tool stopped with exit code 512. Use context menu to get more information.

Note:
- I followed "new_how_to_install_by_renabor.txt" to install LAMW on Ubuntu Mate 64-bit.
- My home folder is "/home/handoko"
- I have no problem to generate Android arm apks
Title: Re: Android Module Wizard
Post by: jmpessoa on April 23, 2016, 06:30:34 pm

Hello Handoko!

In my windows system the "make" and others fpc command line tools is here:

"C:\lazarus\fpc\3.1.1\bin\i386-win32"

Thank you!

Title: Re: Android Module Wizard
Post by: Handoko on April 23, 2016, 06:51:46 pm
I'm a Linux user. Here is my command to find the "make":
Quote
cd /
sudo find -name make

The results are:
Quote
./home/handoko/Android/android-ndk-r11c/prebuilt/linux-x86_64/bin/make
./usr/bin/make
./usr/share/bash-completion/completions/make
./usr/share/doc/make

I'm not a Linux expert, but my guess, the "C:\lazarus\fpc\3.1.1\bin\i386-win32" is in the "/usr/bin" for Linux. But it doesn't work correctly. Can I use the one under the NDK prebuilt?
Title: Re: Android Module Wizard
Post by: Handoko on April 23, 2016, 07:27:19 pm
(continue from my previous post)

./home/handoko/Android/android-ndk-r11c/prebuilt/linux-x86_64/bin/make
is not the correct one. It fails immediately if I click the Build button.

./usr/share/bash-completion/completions/make
is not the correct one. It is a plain text file.

./usr/share/doc/make
is not the correct one. It is a folder.

./usr/bin/make
so it should be this one. But it also fail after several seconds of processing.

In my computer, there are 2 lazarus folder:
Quote
./home/handoko/Android/lazarus
./usr/share/lazarus/1.5.49563

My guess, the first lazarus folder (under Android folder) is the source downloaded by subversion. The second one should be the 'real' lazarus folder. But there is no fpc folder inside them.

Linux store exe and library files in different location compare to Windows. Normally when installing software, Windows will put all related files in a single folder under "Program Files", but Linux seems to distribute them into different folders.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 23, 2016, 08:09:45 pm

Hello Handoko!

Where is your fpc installed?

Where is your fpc  ".../bin"?
Title: Re: Android Module Wizard
Post by: Handoko on April 24, 2016, 05:37:03 am
Where is your fpc installed?

I don't know. I followed "new_how_to_install_by_renabor.txt" instruction to put the downloaded files in "/home/handoko/Android". In the installing process, it never asked me where to put the installed fpc.

I use Linux find command to search my entire harddisk:
Quote
cd /
sudo find -name fpc

And this is the results:
Quote
./home/handoko/Android/fpc
./home/handoko/Android/fpc/utils/javapp/src/fpc
./usr/bin/fpc
./usr/local/lib/fpc
./usr/share/doc/fpc
./usr/share/fpcsrc/3.1.1/utils/javapp/src/fpc
./usr/lib/fpc

The first two under the Android folder are the source that I downloaded. AFAIK, when installing software in Linux, it will put the executable file into /usr/bin, and some other files into .../doc and .../lib folders. Unlike Windows, it doesn't put all the installed files in a single folder (Windows use "Program Files" folder).
Title: Re: Android Module Wizard
Post by: jmpessoa on April 24, 2016, 05:25:35 pm

Quote
./usr/bin/fpc

Well,  the "make" should be in  "/usr/bin", too.
Title: Re: Android Module Wizard
Post by: Handoko on April 24, 2016, 06:56:03 pm
Yes, this is what I used. But it fails.

My settings:
Quote
FPC Source:
/home/handoko/Android/fpc

Path to Android NDK:
/home/handoko/Android/android-ndk-r11c

Path to FPC "make.exe":
/usr/bin

Architecture:
x86

Error message in the popup window:
"Cannot Run Extern [make] Tool!"

Information on the Messages window:
Quote
make[2]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2869: recipe for target 'build-stamp.i386-android' failed
make[1]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2935: recipe for target 'crossall' failed
Panic: tool stopped with exit code 512. Use context menu to get more information.

Does anyone ever succeed to use this "Build FPC Cross Android" feature on Linux? Please share your settings.
Title: Re: Android Module Wizard
Post by: ThreeCat on April 25, 2016, 05:31:01 pm
Good day!
months earlier...I was able to screw "Android Module Wizard" in which Typhone (CodeTyphone) with the replacement of the dependencies two packages! (IDEintf, SynEdit) but today when I try to install from scratch there are incompatible types! (((
When you install lazandroidwizardpack.lpk
log(lamwdesigner.pas(668,58) Error: Incompatible type for arg no. 1: Got "<procedure variable type of procedure(TObject;ShortString) of object;StdCall>", expected "<procedure variable type of procedure(TObject) of object;StdCall>")
Can what is the correct worth in lamwdesigner.pas???
Title: Re: Android Module Wizard
Post by: Handoko on April 25, 2016, 05:46:00 pm
Have you follow the installation instruction?
For Windows: HOW_TO_INSTALL_by_Dieselnutjob.pdf
For Linux: new_how_to_install_by_renabor.txt

If you follow the instruction, you should have no problem.

What version of FPC and Lazarus are you using?
Title: Re: Android Module Wizard
Post by: ThreeCat on April 25, 2016, 06:39:12 pm
No, I have no manual in pdf!(((
fpc 3.1.1 version
Title: Re: Android Module Wizard
Post by: Handoko on April 25, 2016, 07:04:32 pm
If you're a Windows user, you may want to read the thread started by tintinux:
http://forum.lazarus.freepascal.org/index.php/topic,32370.0.html

He also created a new page explaining the installation process:
http://wiki.freepascal.org/LAMW

If you're a CodeTyphon user, you may need to adapt the code. I don't use CodeTyphon, but I heard some say CT makes several necessary changes of real source codes. Currently, LAMW is still on its early stage, fixing some bugs and need updating its documentation. So I don't think the developer will have time to make it compatible with CT soon.
Title: Re: Android Module Wizard
Post by: A.S. on April 25, 2016, 09:59:21 pm
Good day!
months earlier...I was able to screw "Android Module Wizard" in which Typhone (CodeTyphone) with the replacement of the dependencies two packages! (IDEintf, SynEdit) but today when I try to install from scratch there are incompatible types! (((
When you install lazandroidwizardpack.lpk
log(lamwdesigner.pas(668,58) Error: Incompatible type for arg no. 1: Got "<procedure variable type of procedure(TObject;ShortString) of object;StdCall>", expected "<procedure variable type of procedure(TObject) of object;StdCall>")
Can what is the correct worth in lamwdesigner.pas???

Just remove the second parameter of OnDesignerModified (completely remove {$if ..}...{$endif})
Title: Re: Android Module Wizard
Post by: ThreeCat on April 26, 2016, 12:16:54 pm
Quote
Just remove the second parameter of OnDesignerModified (completely remove {$if ..}...{$endif})
thank you! worked...
Title: Re: Android Module Wizard
Post by: Mladen on April 26, 2016, 12:46:25 pm
Hello , dont know if you guys have tried but when ever i tried to use TThread in my android application it doesn't seems to work.

Code inside TThread.Execute never gets executed. I have added
Code: Pascal  [Select][+][-]
  1. {$IFDEF UNIX}{$define UseCThreads}{$IFDEF UseCThreads}
  2.   cthreads,
  3.   {$ENDIF}{$ENDIF}
because without it the application crashes at start. While on simple desktop application it works fine.

I also use jAsyncProcesses but that too also crashes my application when executed for example in
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule2.AndroidModule2JNIPrompt(Sender: TObject);
  2. begin  
  3. jAsyncTask1.execute;
  4. end;
And after some heavier operation for example
Code: Pascal  [Select][+][-]
  1.  for i:=0 to Length(AndroidModule1.myArray)-1 do
  2.     begin
  3.       if AndroidModule1.myArray[i].article=s then
  4.         begin
  5.           jAsyncTask1.execute;
  6.           breaK;
  7.         end;
  8.     end;

while for example when used in on jButton click event it works fine.

Cheers!


Title: Re: Android Module Wizard
Post by: ThreeCat on April 26, 2016, 03:23:10 pm
How to limit permissions of apps? for example write only access to the Internet!
Title: Re: Android Module Wizard
Post by: Handoko on April 26, 2016, 06:50:31 pm
Did you mean this one:

Lazarus Main Menu > Project > Project Options > Project Option Section > [Lamw] Android Manifest

There you can see lots of checkboxes to configure the permissions.
Title: Re: Android Module Wizard
Post by: ThreeCat on April 26, 2016, 06:56:35 pm
thanks!
Title: Re: Android Module Wizard
Post by: ThreeCat on April 26, 2016, 09:00:09 pm
the question of course is trivial... how to remove the header of the form?... on the phone it was not
Title: Re: Android Module Wizard
Post by: tintinux on April 28, 2016, 06:43:15 pm
Hi

Do you want to remove or change the title displayed on the top of the Windows ?
It is the name of the project, or of the folder.

Me too... but sorry I don't know how !

Thanks to anybody who knows !
Title: Re: Android Module Wizard
Post by: jmpessoa on April 28, 2016, 07:04:05 pm


Yes,  the name of the project =  folder.

you can try hide  action bar:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.DataModuleJNIPrompt(Sender: TObject);
  2. begin
  3.         Self.HideActionBar();
  4. end;
  5.  

Thank you!
Title: Re: Android Module Wizard
Post by: Handoko on April 28, 2016, 07:16:11 pm
It also can be changed to something else.

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
  2. begin
  3.   SetTitleActionBar('Hello');
  4. end;

Although it works, but doesn't look good. I can see the 'original' title before it switches to the new name.
Title: Re: Android Module Wizard
Post by: jmpessoa on April 30, 2016, 08:01:01 am

Hello All!

There is a new LAMW revision!

https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 38.9 - 30 April 2016 -

   NEW! Component jAutoTextView

   NEW! jForm propertie and Event:
      ActionBarTitle = (abtDefault,
                                  abtTextAsTitle,      // Get Text property content as Title!
                                  abtTextAsTitleHideLogo,
                                  abtHideLogo,
                                  abtHide)          //<<-- Thanks to Handoko's bug

      OnSpecialKeyDown  // <<---- Thanks to Handoko's suggestion [but, not for Home and Overview, yet. Sorry...]

   NEW! Demo AppAutoCompleteTextViewDemo1

Thanks to All
Title: Re: Android Module Wizard
Post by: ketch on April 30, 2016, 08:11:12 pm
Hi all,

First i want to say that i have discover LAMW recently and i think it is a great solution for Android development with freepascal and lazarus. You have done an amazing work!!!!

I started an application using jCanvasES1. I need to input keyboard entry in the jCanvasES1.
When i touch the JCanvasES1, i can show the keyboard with the instruction ToggleSoftInput but how can i receive the pressed key in jCanvasES1, there is no event for that...
Title: Re: Android Module Wizard
Post by: jmpessoa on May 01, 2016, 07:09:37 am

Hello tintinux!

I got fix the "AppCameraDemo" !!

Hello  ketch!

what keys you need?  jForm,  now have "OnSpecialKeyDown"  event ...
Title: Re: Android Module Wizard
Post by: ketch on May 01, 2016, 12:20:10 pm
Hello jmpessoa!

I render a text editor in jCanvasES1. I need to get what the user press on the soft keyboard.
I have give a try to OnSpecialKeyDown like this:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jCanvasES1_1GLDown(Sender: TObject; Touch: TMouch);
  2. begin
  3.   AndroidModule1.ToggleSoftInput();
  4. end;
  5.  
  6. procedure TAndroidModule1.AndroidModule1SpecialKeyDown(Sender: TObject;
  7.   keyChar: char; keyCode: integer; keyCodeString: string; var mute: boolean);
  8. begin
  9.   ShowMessage('SpecialKeyDown fired');
  10. end;

I press on the jCanvasES1 for show the soft keyboard, then i press some key on the soft keyboard but the SpecialKeyDown even is not fire (the message is never display)...

Maybe i do something wrong...

In addition, i want to have more than one jCanvasES1 with text editor on the screen, i need to get the input only in the one who is focused.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 01, 2016, 07:57:20 pm

Ok ketch!

Please, go to "App.java" [...\src\...] and  uncomment "default"

Quote
@Override
   public boolean onKeyDown(int keyCode, KeyEvent event) {
      switch(keyCode) {
        .......................................
         .......................
        //default: controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode));           
      }
     .......................
   }       

In pascal side

try:

ShowMessage(keyCodeString);
Title: Re: Android Module Wizard
Post by: ketch on May 02, 2016, 01:55:57 am
Hello jmpessoa!

Thank you very much !!!! This modification is what i need.

Why is this code line disable in App.java ?
Title: Re: Android Module Wizard
Post by: Handoko on May 02, 2016, 05:35:42 pm
Hello. I found somethings not working correctly, hope it can be fixed on next release.

1. Can't build FPC 3.1.1 + Lazarus 1.6

I followed the instruction "new_how_to_install_by_renabor.txt" and succeed to install FPC 3.1.1 + Lazarus 1.5 + LAMW. That's great, I was very happy. So I remove all of them and perform a clean installation of FPC 3.1.1 + Lazarus 1.6, but I failed when building Lazarus. Now, I ended with FPC 3.0.0 + Lazarus 1.6 that I installed using deb packages downloaded from SourceForge.

Can someone tell me, FPC 3.1.1 can't be combined with Lazarus 1.6? Or is there anything wrong in the instruction manual?

2. LAMW doesn't accept short version of home folder name

My home folder is "/home/handoko/"
It can be shortened as "~/"

I installed following the installation instruction but I replaced all the "/home/handoko/" with "~/". Nothing went wrong. So, somebody please update the installation guide (to use short version home name).

Unfortunately, LAMW doesn't accept short version of home folder name. If I use the short version name on LAMW configuration form, I'll get error. Please see the attached image.

3. Missing NDK 11c on the configuration form

I use NDK version 11c, but there is no such option on the path setting. Please see the attached image. Strange thing is, everything seems working correctly although I choose 10c but actually I have 11c installed. Why?

4. What is Linux-x8664?

Is it a typing mistake? Please see the attached image.

5. Items on the Ndk Platform listbox aren't properly sorted

It should be 14, 15, 17, 21 ... Please see the attached image.

6. Can't cross build on Linux

I'm sure my Linux make tool is in "/usr/bin" folder. But it said cannot run extern [make] tool.
Title: Re: Android Module Wizard
Post by: ThreeCat on May 08, 2016, 02:43:31 pm
Good day!
Why it does not work when creating the second form's module to migrate to the new method show... the app gives an error... as implemented by the interaction of several forms in this package?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 08, 2016, 08:28:32 pm
Hi  ThreeCat

Quote
...as implemented by the interaction of several forms in this package?

Please, go to demo "AppTest1" [..\jni]

Title: Re: Android Module Wizard
Post by: ThreeCat on May 09, 2016, 09:50:33 am
thanks!
Title: Re: Android Module Wizard
Post by: jmpessoa on May 11, 2016, 04:48:13 am

Hi All!

There is an updated LAMW revision!!

Version 0.6 - rev. 42 - 10 May 2016 -
   
   UPDATE!   AppMenuDemo  // <<--- thanks to Freris!
   FIXED!   OnKyDown [App.java] // <<--- thanks to Freris!

Please,
Upgrade yours projects code templates:
Quote
Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]
Title: Re: Android Module Wizard
Post by: Mladen on May 12, 2016, 11:21:39 am

Hi All!

There is an updated LAMW revision!!

Version 0.6 - rev. 42 - 10 May 2016 -
   
   UPDATE!   AppMenuDemo  // <<--- thanks to Freris!
   FIXED!   OnKyDown [App.java] // <<--- thanks to Freris!

Please,
Upgrade yours projects code templates:
Quote
Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]


Thank you!! I was wandering is there a way to get Device Model name ? Like something similar to getDeviceID.

In Android Studio you can get it by calling android.os.Build.MODEL;
Title: Re: Android Module Wizard
Post by: jmpessoa on May 14, 2016, 07:28:40 am
Quote
I was wandering is there a way to get Device Model name ....

[SOLVED!]

Version 0.6 - rev. 43 - 13 May 2016 -

   NEW!   jForm methods:
            GetDeviceModel,   
            GetDeviceManufacturer // <<--- thanks to Mladen

   NEW!   AppTFPNoGUIGraphicsBridgeDemo8   [scan pixels]// <<--- thanks to Prof. Welligton Pinheiro Santos
      
      image ref.  https://od.lk/f/Ml8xMTgzOTA0Nzdf


Thanks to All!
Title: Re: Android Module Wizard
Post by: Mladen on May 16, 2016, 08:51:34 am
Quote
I was wandering is there a way to get Device Model name ....

[SOLVED!]

Version 0.6 - rev. 43 - 13 May 2016 -

   NEW!   jForm methods:
            GetDeviceModel,   
            GetDeviceManufacturer // <<--- thanks to Mladen

   NEW!   AppTFPNoGUIGraphicsBridgeDemo8   [scan pixels]// <<--- thanks to Prof. Welligton Pinheiro Santos
      
      image ref.  https://od.lk/f/Ml8xMTgzOTA0Nzdf


Thanks to All!

Thank you!
Title: Re: Android Module Wizard
Post by: ThreeCat on May 17, 2016, 01:19:12 am
I tried to run AppTest1 on zte gf3 but it crashes when opening the SDK...everything is set...

In General, make a new project created 2 modules with the main threw the button on the switch to the second (for example AppTest1) - everything turned out, but there is a but!:
when you press the button to close the second module... in fact it needs to close and return to the first - but this is not happening... the app just closes(

////Unit1
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. begin
  3.    if(AndroidModule2 = nil) then
  4.   begin
  5.     gApp.CreateForm(TAndroidModule2, AndroidModule2);
  6.     AndroidModule2.TryBacktrackOnClose:= True;
  7.     //AndroidModule2.PromptOnBackKey:= False;
  8.     AndroidModule2.Init(gApp);
  9.   end
  10.   else
  11.   begin
  12.     AndroidModule2.Show;
  13.   end;
  14. end;                  
  15.  
/////Unit2
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule2.jButton1Click(Sender: TObject);
  2. begin
  3.   AndroidModule2.Close;
  4. end;
  5.  
     
**********************************************



maybe I missed something?
Title: Re: Android Module Wizard
Post by: tintinux on May 17, 2016, 07:27:42 am
Hi

Set ActivityMode := actRecyclable in the second form, at designtime or in the code.

If possible, I suggest this could be the default value, except for the first form.

Regards
Title: Re: Android Module Wizard
Post by: ThreeCat on May 17, 2016, 07:50:02 am
Yes, it is! thank you very much
Title: Re: Android Module Wizard
Post by: ThreeCat on May 17, 2016, 11:17:33 am
*appmenudemo* and so almost every demo app(((
what can be the reason?

phone ERROR LOG
05-17 11:59:54.266   162   162 I DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-17 11:59:54.266   162   162 I DEBUG   : Native Crash TIME: 98215246
05-17 11:59:54.266   162   162 I DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-17 11:59:54.266   162   162 I DEBUG   : Build fingerprint: 'ZTE/P731A10/P731A10:5.0.1/LRX21M/20151030.113640:user/release-keys'
05-17 11:59:54.266   162   162 I DEBUG   : Revision: '0'
05-17 11:59:54.266   162   162 I DEBUG   : ABI: 'arm'
05-17 11:59:54.266   162   162 I DEBUG   : pid: 9115, tid: 9115, name: ple.appmenudemo  >>> com.example.appmenudemo <<<
05-17 11:59:54.266   162   162 I DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
05-17 11:59:54.296   162   162 I DEBUG   : Abort message: 'art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallIntMethod called with pending exception 'java.lang.NoSuchMethodError' thrown in void com.example.appmenudemo.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout):-2'
05-17 11:59:54.296   162   162 I DEBUG   :     r0 00000000  r1 0000239b  r2 00000006  r3 00000000
05-17 11:59:54.296   162   162 I DEBUG   :     r4 b6fbc114  r5 00000006  r6 00000002  r7 0000010c
05-17 11:59:54.296   162   162 I DEBUG   :     r8 00000000  r9 b504f520  sl b5007800  fp 00000001
05-17 11:59:54.296   162   162 I DEBUG   :     ip 0000239b  sp be996a00  lr b6f44e4d  pc b6f678f0  cpsr 60070010
05-17 11:59:54.296   162   162 I DEBUG   :
05-17 11:59:54.296   162   162 I DEBUG   : backtrace:
05-17 11:59:54.296   162   162 I DEBUG   :     #00 pc 000398f0 
/system/lib/libc.so (tgkill+12)
05-17 11:59:54.296   162   162 I DEBUG   :     #01 pc 00016e49  /system/lib/libc.so (pthread_kill+52)
05-17 11:59:54.296   162   162 I DEBUG   :     #02 pc 00017a5f  /system/lib/libc.so (raise+10)
05-17 11:59:54.296   162   162 I DEBUG   :     #03 pc 000143b1  /system/lib/libc.so (__libc_android_abort+36)
05-17 11:59:54.296   162   162 I DEBUG   :     #04 pc 00012a50  /system/lib/libc.so (abort+4)
05-17 11:59:54.296   162   162 I DEBUG   :     #05 pc 002160dd  /system/lib/libart.so (art::Runtime::Abort()+160)
05-17 11:59:54.296   162   162 I DEBUG   :     #06 pc 000a6c7d  /system/lib/libart.so (art::LogMessage::~LogMessage()+1312)
05-17 11:59:54.296   162   162 I DEBUG   :     #07 pc 000b02d5  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1068)
05-17 11:59:54.296   162   162 I DEBUG   :     #08 pc 000b081f  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+58)
05-17 11:59:54.296   162   162 I DEBUG   :     #09 pc 000b38c3  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1270)
05-17 11:59:54.296   162   162 I DEBUG   :     #10 pc 000b96c1  /system/lib/libart.so (art::CheckJNI::CallIntMethod(_JNIEnv*, _jobject*, _jmethodID*, ...)+36)
05-17 11:59:54.296   162   162 I DEBUG   :     #11 pc 0004d444  /data/app/com.example.appmenudemo-1/lib/arm/libcontrols.so
Title: Re: Android Module Wizard
Post by: jmpessoa on May 17, 2016, 06:43:57 pm

Hi ThreeCat!

Quote
...JNI DETECTED ERROR IN APPLICATION:
JNI CallIntMethod called with pending exception 'java.lang.NoSuchMethodError'  thrown in
void com.example.appmenudemo.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout)...

Code: Pascal  [Select][+][-]
  1. ... JNI CallIntMethod called .... java.lang.NoSuchMethodError ...
  2.  

Please, try update your LAMW from github
and configure the demo ".lpi" according to your system ...
[there is "how to use demos" in "readme.txt"]

Title: Re: Android Module Wizard
Post by: ThreeCat on May 18, 2016, 09:59:58 am
Hi jmpessoa!
thanks for the reply!

After reinstalling from scratch on a new version... still the same problems:
When you add to the form jView and when the app launches on the phone an error occurs, as well checked with another phone - the same (((

PROJECT: https://yadi.sk/d/Q_RFE8hNroAc3
Title: Re: Android Module Wizard
Post by: jmpessoa on May 18, 2016, 06:59:35 pm

Hi ThreeCat!

Possible problems:

1.  jView1  require  jCanvas 
[sorry ... Lamw fail...]

2. NDK installed in  "D:\" 

3. About App "demos": Keep [templates] up to date!

Lazarus IDE menu "Tools"---> "[Lamw] Android Module Wizard" ---> "Upgrade Code Templates"
and more:  configure ".lpi" according to your system.


Title: Re: Android Module Wizard
Post by: ThreeCat on May 18, 2016, 08:01:24 pm
Thank you!
Yes... the way it is! needed jCanvas
Title: Re: Android Module Wizard
Post by: ThreeCat on May 19, 2016, 10:40:17 am
The question is why this construction, when running on the phone banging the application?(((
individually connection and transition to the second shape - everything works

and why, if not to check for the existence of the second form if it is available also the app crashes?


Code: Pascal  [Select][+][-]
  1. con:=false;
  2.      try
  3.       tcp.ConnectAsync('192.168.43.132',7777);
  4.       con:=true;
  5.      except
  6.         con:=false;
  7.      end;
  8.  if con=true then
  9.   begin
  10.  
  11.   if(AndroidModule2 = nil) then
  12.       begin
  13.            gApp.CreateForm(TAndroidModule2, AndroidModule2);
  14.            AndroidModule2.TryBacktrackOnClose:= True;
  15.            //AndroidModule2.PromptOnBackKey:= False;
  16.            AndroidModule2.Init(gApp);
  17.        end else
  18.        begin
  19.         AndroidModule2.Show;
  20.        end;
  21.  
  22.   end else self.ShowMessage('Connection problems!');
  23.  

If you'll excuse a little too insistent demand from you information... I think this is a big plus to the development of this project in terms of testing, as part of my small knowledge

thank you for what you are working in this direction! (not all have power iron that would work in Android Studio and not everyone likes java)
Title: Re: Android Module Wizard
Post by: ThreeCat on May 19, 2016, 12:14:21 pm
Even so not working ((((


Code: Pascal  [Select][+][-]
  1. procedure tcpconnect;
  2. begin
  3.  con:=false;
  4.       try
  5.       AndroidModule1.tcp.ConnectAsync('192.168.43.132',7777);
  6.       con:=true;
  7.       except
  8.         con:=false;
  9.       end;
  10. end;
  11.  
  12. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  13. begin
  14.  
  15.  tcpconnect;
  16.  if con=true then
  17.   begin
  18.   if(AndroidModule2 = nil) then
  19.       begin
  20.        gApp.CreateForm(TAndroidModule2, AndroidModule2);
  21.        AndroidModule2.TryBacktrackOnClose:= True;
  22.        AndroidModule2.PromptOnBackKey:= False;
  23.        AndroidModule2.Init(gApp);
  24.  
  25.        end
  26.         else
  27.        begin
  28.         AndroidModule2.Show;
  29.        end;
  30.   end else self.ShowMessage('Connection problems!');
  31. end;                                                      
  32.  
Title: Re: Android Module Wizard
Post by: ThreeCat on May 19, 2016, 12:36:07 pm
this works...but still, those designs should be the same to work...
maybe the problem is in the ***time interval*** between connecting and opening the second form?
Code: Pascal  [Select][+][-]
  1. procedure tcpconnect;
  2. begin
  3.  con:=false;
  4.       try
  5.       AndroidModule1.tcp.ConnectAsync('192.168.43.132',7777);
  6.       con:=true;
  7.       except
  8.         con:=false;
  9.       end;
  10. end;
  11.  
  12. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  13. begin
  14.  tcpconnect;
  15.  if con=false then self.ShowMessage('Connection problems!');
  16. end;                        
  17.  
  18.  
  19. procedure TAndroidModule1.TCPConnected(Sender: TObject);
  20. begin
  21.   if(AndroidModule2 = nil) then
  22.       begin
  23.        gApp.CreateForm(TAndroidModule2, AndroidModule2);
  24.        AndroidModule2.TryBacktrackOnClose:= True;
  25.        AndroidModule2.PromptOnBackKey:= False;
  26.        AndroidModule2.Init(gApp);
  27.  
  28.        end
  29.         else
  30.        begin
  31.         AndroidModule2.Show;
  32.        end;
  33. end;          
  34.  
Title: Re: Android Module Wizard
Post by: ThreeCat on May 19, 2016, 12:47:50 pm
and still not clear! - How can there be when there is no server when connecting to it the procedure is allegedly a connection with the server was? - performed OnConnected.....
Title: Re: Android Module Wizard
Post by: jmpessoa on May 19, 2016, 08:23:39 pm

Hi ThreeCat!

in fact, the connection is asynchronous ["non-blocking"] so you need:

1. hanlde "OnConnected" to set "con:= True" and create new form.

2. handle  "OnMessagesReceived" to read the data received ...

There is an "AppTCPClientDemo1"  in "demos"  ...

Please try google:  "why should I use non-blocking or blocking sockets?"

Ok. As soon as possible I will try to implement the blocking: jTCPSocketClient1.Connect("","") mode.



Title: Re: Android Module Wizard
Post by: jmpessoa on May 21, 2016, 08:58:58 am

Hi All!

There is an updated LAMW revision:

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 44 - 21 May 2016 -

   NEW!   jDrawingView component      //   <<---- thanks to tintinux

   NEW!   AppDrawingViewDemo1

   NEW!   jNotificationManager methods:
            SetLightsColorAndTime,  //   <<--- thanks to freris
            SetLightsEnable   

   UPDATED!   AppDemo1 
   UPDATED!   AppNotificationManagerDemo1 

   FIXED! jForm property set "ActivityMode:= actRecyclable" as from the second form... //<<---- thanks to tintinux

Thanks to All!
Title: Re: Android Module Wizard
Post by: noisy on May 21, 2016, 04:28:27 pm
How can i set flag FLAG_KEEP_SCREEN_ON for disable sreen off?
java code
Code: Java  [Select][+][-]
  1. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Title: Re: Android Module Wizard
Post by: jmpessoa on May 21, 2016, 06:13:21 pm
Hi noisy!

Quote
How can i set flag FLAG_KEEP_SCREEN_ON for disable sreen off?

Version 0.6 - rev. 45 - 21 May 2016 -

   NEW!   jForm methods:
         SetKeepScreenOn 
         SetTurnScreenOn
         SetAllowLockWhileScreenOn
         SetShowWhenLocked


Please, try handle jForm "OnJNIPrompt":

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
  2. begin
  3.   Self.SetKeepScreenOn();
  4. end;
  5.  

Thank you!
Title: Re: Android Module Wizard
Post by: noisy on May 21, 2016, 08:08:36 pm
Awesome, less two hours for new feature!

but...
Compile Project, OS: android, CPU: arm, Target: E:\FreePascal\4Android\projects\LamwGUIProjectOnScreen\libs\armeabi-v7a\libcontrols.so: Exit code 1, Errors: 3
unit1.pas(36,8) Error: identifier idents no member "SetKeepScreenOn"
Title: Re: Android Module Wizard
Post by: jmpessoa on May 21, 2016, 08:48:38 pm


Hi noisy!

suggestions:

1. After update the LAMW framework from github recompile [and install] the packages ....

problems? try "more"--> "recompile clean"

2. if "old' project:  upgrade your project:

go to menu "Tools"--> [Lamw] Android Module Wizard --> Upgrade code Templates

3. Try clear all your project:  menu "Run" --> Clean up and Build

Title: Re: Android Module Wizard
Post by: noisy on May 22, 2016, 01:33:15 am
Thank you.
Clean up and Build - helped me.

with Self.SetKeepScreenOn() my application(API 16) show form and closes
without ScreenOn works fine


mayby need some rights in AndroidManifest.xml ?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2016, 02:35:13 am

Hi noisy!

ref. "version 0.6 - revision 45.2 - 21 May - 2016"

I have made a little change to jFomr methods signature:

    procedure SetKeepScreenOn(_value: boolean);
    procedure SetTurnScreenOn(_value: boolean);
    procedure SetAllowLockWhileScreenOn(_value: boolean);
    procedure SetShowWhenLocked(_value: boolean);

Please, update your system ["AndroidWidget.pas" and  "Controls.java" in "...\java\"]

Now we can turn "On" and "Off" !!!

Quote
mayby need some rights in AndroidManifest.xml ?

No.

Please, try from some "OnClick" to "On"  and "Off".






Title: Re: Android Module Wizard
Post by: noisy on May 22, 2016, 03:45:09 pm
I am downloaded last LAMW and created new empty LAMW application

add on form only jButton with code
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. begin
  3.   FSwitchMode := not FSwitchMode;
  4.   Self.SetKeepScreenOn(FSwitchMode);
  5. end;
  6.  
but not can compile project. I have tried all your suggestions and nothing.

    [javac] 45 errors
    [javac] 3 warnings

full compile log at url https://cloud.mail.ru/public/FRMn/imGbANGRg
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2016, 09:45:37 pm

Hi Noisy

Quote
E:\FreePascal\4Android\projects\TestScreenMode\src\example\com\testscreenmode\Controls.java:169: error: cannot find symbol

import android.media.MediaPlayer.OnTimedTextListener;    // <<< -------------------------


But, "import android.media.*"   is quite old here.

Please, check your system! 




Title: Re: Android Module Wizard
Post by: noisy on May 22, 2016, 09:57:59 pm
All works fine!
Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on May 24, 2016, 07:29:27 pm

Hi All!

There is a new LAMW revision!

ref.   https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 46 - 24 May 2016 -

   NEW!   jAlarmManager component
   NEW!   AppAlarmManagerDemo1

Thanks to All!

Title: Re: Android Module Wizard
Post by: Handoko on May 29, 2016, 01:15:04 pm
How to disable auto screen rotate when rotating the device?
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 29, 2016, 04:15:26 pm
Hi Handoko

For only vertical screen I added in "AndroidManifest.xml" this code.

Quote
android:screenOrientation="portrait"

 in the line  activity.

Quote
<activity android:name="org.lazarus.rx3android.App" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|screenSize|screenLayout|fontScale"
Title: Re: Android Module Wizard
Post by: Handoko on May 29, 2016, 04:31:28 pm
Thanks you rx3.fireproof.
I'll try it.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 29, 2016, 05:50:20 pm

Hello rx3!
Hello Handoko!

We can try  [too]:

   Self.SetScreenOrientationStyle(ssPortrait);

  or:

   Self.SetScreenOrientationStyle(ssLandscape);

   etc...

handling events: "OnJNIPrompt" or "OnRotate" handle...
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 29, 2016, 06:31:12 pm
Hello jmpessoa!

Well. I'll try.
"My method" for the old version LAMW ;)
Title: Re: Android Module Wizard
Post by: Handoko on May 29, 2016, 07:31:01 pm
Tested using AndroidManifest.xml and SetScreenOrientationStyle. Both work.

Thank you.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 12, 2016, 08:28:03 am

Hello All!

There is an updated LAMW revision!

ref. https://github.com/jmpessoa/lazandroidmodulewizard


Version 0.6 - rev. 47 - 11 June 2016 -

   NEW!   jDownloadService component
   NEW!   jDownloadManager component

   NEW!   AppDownloadServiceDemo1
   NEW!   AppDownloadManagerDemo1

   IMPROVED!
      jGridView   // <<---- thanks to tintinux suggestions
         New methods:
            SetHorizontalSpacing
            SetVerticalSpacing
            SetSelection
            SetStretchMode

      jDrawingView   // <<---- thanks to tintinux suggestions
         New events:
            OnFlingGesture
            OnPinchZoomGesture
         Changed:
            OnDraw signature

   UPDATED:
      AppGridViewDemo1
      AppDrawingViewDemo1   


Thanks to All!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on June 12, 2016, 09:23:14 pm
Hello jmpessoa!

In the new version I have a little error. The "ant/bin"  path is not saved in the path settings.
Shows the path to the SDK.
From command line everything works.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 13, 2016, 02:52:32 am


Quote
...The "ant/bin"  path is not saved in the path settings.

Fixed!

Thank you!
Title: Re: Android Module Wizard
Post by: rx3.fireproof on June 13, 2016, 07:03:36 pm
Hello jmpessoa!

Everything works. Thank you.

I have long wanted to ask.
It is possible to add a property "alignment"  to a jSpinner ?  ::)
Title: Re: Android Module Wizard
Post by: jmpessoa on July 12, 2016, 07:48:47 am

Hello All!

There is a Major  LAMW update!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7 - 11 July 2016

   WARNING!
      .Uninstall all LAMW package before install the new version 0.7
         .uninstall [amw_ide_tools.lpk]
         .uninstall [lazandroidwizardpack.lpk]
         .uninstall [tfpandroidbridge_pack.lpk]   // <--- uninstall at last!
   
   IMPROVEMENTS!
      .Smart code composition/generation     [old @leledumbo suggestion!]
      .Smart "Demos" perception/detection and [ndk/sdk] paths auto-fixed
      .Automatic java templates update/synchronization

   CLEANUP! [new folders organization]
      .android_bridges   [tfpandroidbridge_pack.lpk] // <<-- install first
      .android_wizard      [lazandroidwizardpack.lpk]
      .ide_tools      [amw_ide_tools.lpk]
      .java
         .lamwdesigner
      .docs
         .linux

   CLEANUP!
      .Component tabs organization


   WARNING!
      .Please, whenever a dialog prompt, select "Reload from disk"


   NEW!   jChronometer component
   NEW!   jMediaRecorder component   //thanks to  Mario H. D. suggestion!

   NEW!   AppChronometerDemo1
   NEW!   AppMediaRecorderDemo1      //thanks to  Mario H. D. suggestion!

Thanks to All!
Title: Re: Android Module Wizard
Post by: Handoko on July 12, 2016, 08:19:37 am
Just downloaded and updated. Thank you.
Title: Re: Android Module Wizard
Post by: x2nie on July 12, 2016, 12:47:52 pm
hi @jmpessoa, would you like to add screenshot of running demos? if you can't, a photo (by camera) is okay. 8-)
Title: Re: Android Module Wizard
Post by: Handoko on July 14, 2016, 04:56:06 pm
Hello, jmpessoa.

After I upgraded LAMW to version 0.7 yesterday, now I always get the message telling me to "Reload from disk" or "Ignore disk changes" when I open my old project, even I've already reload and saved it.

Is it a new behavior set by intention? Or bug? Or something wrong with my project file? Please see the attached image.
Title: Re: Android Module Wizard
Post by: jmpessoa on July 14, 2016, 07:35:14 pm
Hello Handoko!

Yes, "Is it a new [weird] behavior set by intention" to keeps up to date the "java templates" code.... but we will try to avoid this frequent call.

For now, please, always choose "Reload from disk"!

Thank you!

NOTE: You can see a "checkbox" in your image: check it!



Title: Re: Android Module Wizard
Post by: jmpessoa on July 17, 2016, 06:39:31 pm
Now, there is a little fix [lamwdesigner.pas], to avoid frequent "Reload from

disk" when  the  project is re-open...

We need check this option when the dialog prompt:

Quote
(x) Check for disk file changes via content rather than timestamp

NOTE: as always after the update, we need to re-install the package
[lazandroidwizardpack.lpk]
Title: Re: Android Module Wizard
Post by: renabor on July 30, 2016, 07:56:01 am
Now, there is a little fix [lamwdesigner.pas], to avoid frequent "Reload from

disk" when  the  project is re-open...

We need check this option when the dialog prompt:

Quote
(x) Check for disk file changes via content rather than timestamp

NOTE: as always after the update, we need to re-install the package
[lazandroidwizardpack.lpk]
Hello @jmpessoa!

How can I maintain my copy of Controls.java instead of having it everytime overwrite?

thankyou!
Title: Re: Android Module Wizard
Post by: jmpessoa on July 30, 2016, 07:40:48 pm

Hello Renabor [welcome, again!  :D :D]!

No Problem. I will open this possibility....

but, if appropriate you can also update the github... [ok,
there is a new [and smart] code architecture!]

Title: Re: Android Module Wizard
Post by: Handoko on July 30, 2016, 08:01:21 pm
Is it the name that mentioned several times in the documentation and the one who wrote the how to install tutorial? Wow, it's great if he back and join the development.  :D
Title: Re: Android Module Wizard
Post by: jmpessoa on August 01, 2016, 12:03:47 am
@renabor

Quote
How can I maintain my copy of Controls.java instead of having it everytime overwrite?

Please,  first get update from github and then
go to "JNIAndroidProject.ini"  in folder "lazarus/config" and
add this line:
Code: Pascal  [Select][+][-]
  1. CanUpdateJavaTemplate=f
  2.  
"f" to "false",  any other value will be "true".

NOTE: this will break update to all ".java"...
[but, "old" projects before LAMW 0.7 will be update!]
Title: Re: Android Module Wizard
Post by: renabor on August 03, 2016, 03:55:30 pm

Hello Renabor [welcome, again!  :D :D]!

No Problem. I will open this possibility....

but, if appropriate you can also update the github... [ok,
there is a new [and smart] code architecture!]

Hello @jmpessoa!
Because of a new job  :D in a remote city  :o free time to spend in developing was tending to zero and so I have disappeared for some time.
My hope is to be more free now, to continue to contribute to your great project!
github? Yes off course, when my testing on jSqlite and an improved jListView are done I will post code on github for sure;-)
Thank you!
Title: Re: Android Module Wizard
Post by: renabor on August 03, 2016, 04:01:11 pm
Is it the name that mentioned several times in the documentation and the one who wrote the how to install tutorial? Wow, it's great if he back and join the development.  :D

Hello Handoko!
great to meet you in development  :D and thanks for the tips on how to improve the linux install tutorial. A revision is planned ;-)
Title: Re: Android Module Wizard
Post by: renabor on August 03, 2016, 04:02:54 pm
@renabor

Quote
How can I maintain my copy of Controls.java instead of having it everytime overwrite?

Please,  first get update from github and then
go to "JNIAndroidProject.ini"  in folder "lazarus/config" and
add this line:
Code: Pascal  [Select][+][-]
  1. CanUpdateJavaTemplate=f
  2.  
"f" to "false",  any other value will be "true".

NOTE: this will break update to all ".java"...
[but, "old" projects before LAMW 0.7 will be update!]

Great! Now my hacked java files are safe ;-)

Thank you!
Title: Re: Android Module Wizard
Post by: renabor on August 04, 2016, 08:07:09 am
Hello @jmpessoa!

Creating a new lamw gui project I got this error:

Quote
Error reading CheckBox1.OnClick: Invalid value for property

any advice?

other question is about target i386-android.
Installed my app in an emulated Nexus 10 x86, running Android 5.0.1, but launching the app what i got is this error:

Quote
Code: XML  [Select][+][-]
  1. I/ActivityManager( 1486): Start proc com.suevoz.borsa for activity com.suevoz.borsa/.App: pid=2185 uid=10053 gids={50053, 9997, 3003, 1028, 1015} abi=x86
  2. W/ActivityThread( 2185): Application com.suevoz.borsa can be debugged on port 8100...
  3. I/Zygote  ( 1145): Process 2185 exited cleanly (217)
  4. W/libprocessgroup( 1486): failed to open /acct/uid_10053/pid_2185/cgroup.procs: No such file or directory
  5. I/ActivityManager( 1486): Process com.suevoz.borsa (pid 2185) has died
  6. E/libprocessgroup( 2203): failed to make and chown /acct/uid_10053: Read-only file system
  7. W/Zygote  ( 2203): createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
  8. I/art     ( 2203): Not late-enabling -Xcheck:jni (already on)
  9. I/ActivityManager( 1486): Start proc com.suevoz.borsa for activity com.suevoz.borsa/.App: pid=2203 uid=10053 gids={50053, 9997, 3003, 1028, 1015} abi=x86
  10. W/ActivityThread( 2203): Application com.suevoz.borsa can be debugged on port 8100...
  11. W/libprocessgroup( 1486): failed to open /acct/uid_10053/pid_2203/cgroup.procs: No such file or directory
  12. I/ActivityManager( 1486): Process com.suevoz.borsa (pid 2203) has died
  13. I/Zygote  ( 1145): Process 2203 exited cleanly (217)
  14. E/libprocessgroup( 2219): failed to make and chown /acct/uid_10053: Read-only file system
  15. W/Zygote  ( 2219): createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
  16. I/ActivityManager( 1486): Start proc com.suevoz.borsa for activity com.suevoz.borsa/.App: pid=2219 uid=10053 gids={50053, 9997, 3003, 1028, 1015} abi=x86
  17. I/art     ( 2219): Not late-enabling -Xcheck:jni (already on)
  18. W/ActivityThread( 2219): Application com.suevoz.borsa can be debugged on port 8100...
  19. W/libprocessgroup( 1486): failed to open /acct/uid_10053/pid_2219/cgroup.procs: No such file or directory
  20. I/ActivityManager( 1486): Process com.suevoz.borsa (pid 2219) has died
  21. W/ActivityManager( 1486): Force removing ActivityRecord{206ba514 u0 com.suevoz.borsa/.App t26}: app died, no saved state
  22. I/Zygote  ( 1145): Process 2219 exited cleanly (217)
  23. W/WindowManager( 1486): Failed looking up window
  24. W/WindowManager( 1486): java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@2e0c19f1 does not exist
  25. W/WindowManager( 1486):         at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8413)
  26. W/WindowManager( 1486):         at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8404)
  27. W/WindowManager( 1486):         at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2558)
  28. W/WindowManager( 1486):         at com.android.server.wm.Session.remove(Session.java:186)
  29. W/WindowManager( 1486):         at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2920)
  30. W/WindowManager( 1486):         at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5390)
  31. W/WindowManager( 1486):         at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3223)
  32. W/WindowManager( 1486):         at android.os.Handler.dispatchMessage(Handler.java:102)
  33. W/WindowManager( 1486):         at android.os.Looper.loop(Looper.java:135)
  34. W/WindowManager( 1486):         at android.os.HandlerThread.run(HandlerThread.java:61)
  35. W/WindowManager( 1486):         at com.android.server.ServiceThread.run(ServiceThread.java:46)
  36. W/InputMethodManagerService( 1486): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@fb7642d attribute=null, token = android.os.BinderProxy@64ce490
  37. D/TaskPersister( 1486): removeObsoleteFile: deleting file=26_task.xml
  38.  

Can you help me understand what I'm doing wrong?

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on September 04, 2016, 03:09:57 pm
Hi All!

There is a new LAMW feature...

ref. https://github.com/jmpessoa/lazandroidmodulewizard


Version 0.7.1 - 03 September - 2016

   NEW! Added Support to java code/stuff reuse [ide_tools]
      IDE menu "Tools" --> "[Lamw] Android Module Wizard" --> "Use/Import Java Stuff..."

   NEW! jActivityLauncher component  [support to native android "Activity" code reuse]

   NEW! AppActivityLauncherDemo1
       Note/hint/highligh:  "AndroidManifest.xml" requires:

         <activity
            android:name="com.example.appactivitylauncherdemo1.MyActivity1"
            android:label="@string/app_name"
            android:launchMode="standard" android:enabled="true">
         </activity>
         <activity
            android:name="com.example.appactivitylauncherdemo1.MyActivity2"
            android:label="@string/app_name"
            android:launchMode="standard" android:enabled="true">
         </activity>

Thanks to All!
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 08, 2016, 12:23:03 pm
Hi jmpessoa,

I would like to ask for a feature.
I am using the jDatePickerDialog.
But when it shows, its always on the date of today.
It would be very nice to control the date when the popup shows !
Or am I missing something ?

Thanks in advance, Alfred.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 08, 2016, 08:59:57 pm

Hi  Alfred,

I just Improved jDatePickerDialog and jTimePickerDialog

There is a Show method overloaded....

and an updated  "AppDateTimePicker  demo".

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton3Click(Sender: TObject);
  2. begin
  3.   jTimePickerDialog1.Show(15, 15);  //example
  4. end;
  5.  
  6. procedure TAndroidModule1.jButton4Click(Sender: TObject);
  7. begin
  8.   jDatePickerDialog1.Show(2015, 2, 3);  //example
  9. end;
  10.  

Thank you!



Title: Re: Android Module Wizard
Post by: DonAlfredo on September 09, 2016, 08:11:10 am
Working as expected. Thank you !!
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 09, 2016, 01:07:46 pm
Hi jmpessoa,

Having another problem now (not related to the previous one).

I am trying to make a simple calendar by drawing some lines onto a jDrawingView.
When this DrawingView is placed on a ScrollView, it will no longer be visible.
However, when looking at the sources, this should be possible.
(I need to touch-scroll the DrawingView)

Can you help ?
Thanks.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 10, 2016, 07:02:12 am
Hi Alfred,

I got success with the following settings:

jScrollView1:
Quote
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpHalfOfParent
    ScrollSize = 2000

jDrawingView1:
Quote
      PosRelativeToParent = [rpCenterInParent]
      LayoutParamWidth = lpMatchParent
      LayoutParamHeight = lpSevenEighthOfParent

Code: Pascal  [Select][+][-]
  1.   TAndroidModule1 = class(jForm)
  2.     jDrawingView1: jDrawingView;
  3.     jScrollView1: jScrollView;
  4.     procedure AndroidModule1Create(Sender: TObject);
  5.     procedure jDrawingView1Draw(Sender: TObject);
  6.     procedure jDrawingView1TouchMove(Sender: TObject; Touch: TMouch);
  7.   private
  8.     {private declarations}
  9.   public
  10.     {public declarations}
  11.     P: TPoint;
  12.   end;
  13.  
  14. var
  15.   AndroidModule1: TAndroidModule1;
  16.  
  17. implementation
  18.  
  19. {$R *.lfm}
  20.  
  21. { TAndroidModule1 }
  22.  
  23. procedure TAndroidModule1.jDrawingView1Draw(Sender: TObject);
  24. var
  25.   w1, h1: integer;
  26. begin
  27.   w1:= jDrawingView1.Width;
  28.   h1:= jDrawingView1.Height;
  29.  
  30.   //Frame
  31.   jDrawingView1.DrawLine(0,0,0,h1-1);
  32.   jDrawingView1.DrawLine(0,h1-1,w1-1,h1-1);
  33.   jDrawingView1.DrawLine(w1-1,h1-1,w1-1,0);
  34.   jDrawingView1.DrawLine(w1-1,0,0,0);
  35.  
  36.   jDrawingView1.DrawText('Drawing Test....',P.X,P.Y);
  37.   jDrawingView1.DrawText('P(x,y)=(' + IntToStr(P.X) + ',' + IntToStr(P.Y)+')',10,h1-30);
  38. end;
  39.  
  40. procedure TAndroidModule1.jDrawingView1TouchMove(Sender: TObject; Touch: TMouch);
  41. begin
  42.   P:= Point(Round(Touch.Pt.X), Round(Touch.Pt.Y));
  43.   jDrawingView1.Refresh;   //call OnDraw ....
  44. end;
  45.  
  46. procedure TAndroidModule1.AndroidModule1Create(Sender: TObject);
  47. begin
  48.   P.X:= 100;
  49.   P.Y:= 100;
  50. end;
  51.  
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 10, 2016, 07:20:34 am
Thanks.
And yes, that works ... but on my phone, the drawview does not fill the scrollview for 100%.
So, I am still investigating.

In the meantime, pleae find attached a new addition for scrollview : setFillViewport.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 10, 2016, 07:38:42 am

Thanks!

I will apply it!
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 10, 2016, 10:51:58 am
Some intermediate results.

I saw in your source that you put a relative layout inside the scrollview.
I know that you have to do this to allow for more childs, while a scrollview can only handle a single child.

In my case, I have a single child (very high drawingview) that has to scroll with the scrollview.
IMHO, I think that we need a new basic scrollview without relative layout for situations where there is only a single child !
Title: Re: Android Module Wizard
Post by: renabor on September 12, 2016, 06:38:14 pm
Hallo @jmpessoa!
With latest change i'm unable to compile due to something related with (i suppose) new Canvas.
Error message that I got is this:

Code: Java  [Select][+][-]
  1. E/art     (21788): Failed to register native method com.suevoz.borsa.Controls.pOnGLRenderer(JIII)V in /data/app/com.suevoz.borsa-2/base.apk
  2. D/AndroidRuntime(21788): Shutting down VM
  3. E/AndroidRuntime(21788): FATAL EXCEPTION: main
  4. E/AndroidRuntime(21788): Process: com.suevoz.borsa, PID: 21788
  5. E/AndroidRuntime(21788): java.lang.NoSuchMethodError: no static or non-static method "Lcom/suevoz/borsa/Controls;.pOnGLRenderer(JIII)V"
  6.  

have you any advice?

thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on September 12, 2016, 08:25:10 pm
Hi Renabor,

please go to menu "Run" --> "Clean up an Build" ...

The "pOnGLRenderer"  was droped...

Now we have:

 "pOnGLRenderer1" for jCanvasES1

and

 "pOnGLRenderer2" for jCanvasES2


NOTE:  if you are using "old" "Controls.java"  then you will need upgrade
your project and then to do some "custom/hack" in the new code architecture....
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 14, 2016, 08:07:37 am
@jmpessoa
Please find attached a new version of drawingview.
This version can be dropped on a FrameLayout (i.e. scrollview) as well as on a RelativeLayout.

This drawing view itself is not that imortant however.
The included patch should be applied to all (visual) components.
It will allow all components to have a FrameLayout and RelativeLayout parent !!

Please review. I hope you will apply this patch.
It makes all components more flexible !

Edit:
And, if you like it, you can easily add a linear layout too !!
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 14, 2016, 12:49:05 pm
Added LinearLayout into patch !
Title: Re: Android Module Wizard
Post by: jmpessoa on September 14, 2016, 08:45:27 pm


Hi Alfred!

Please, commit yours patchs!

If something stops working we will help to solve!

thank you!
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 15, 2016, 01:06:06 pm
Done !
Lots of code changes ... beware of the typos ...  %)
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 16, 2016, 12:21:14 pm
@jmpessoa --> Feature request !

I would like to ask you for the possibility to add a canvas to ListView.
At the moment, I am doing this (on a long viewlist):

Code: Java  [Select][+][-]
  1. @Override
  2. public  void onDraw( Canvas canvas) {
  3.                 super.onDraw(canvas);
  4.                 View c = super.getChildAt(0);
  5.                 int scrollposition = -c.getTop() + super.getFirstVisiblePosition() * (c.getHeight()+super.getDividerHeight());
  6.                 Paint myPaint = new Paint();
  7.                 myPaint.setColor(Color.rgb(200, 0, 0));
  8.                 myPaint.setStrokeWidth(25);
  9.                 myPaint.setStyle(Paint.Style.STROKE);
  10.                 canvas.drawRect(100, 800 - scrollposition, 200, 900 - scrollposition, myPaint);
  11.         }
  12.  
  13. @Override
  14. protected void dispatchDraw(Canvas canvas) {
  15.                 super.dispatchDraw(canvas);
  16.                 View c = super.getChildAt(0);
  17.                 int scrollposition = -c.getTop() + super.getFirstVisiblePosition() * (c.getHeight()+super.getDividerHeight());
  18.                 Paint myPaint = new Paint();
  19.                 myPaint.setColor(Color.rgb(0, 200, 0));
  20.                 myPaint.setStrokeWidth(25);
  21.                 myPaint.setStyle(Paint.Style.STROKE);
  22.                 canvas.drawRect(100, 2000 - scrollposition, 400, 2200-scrollposition, myPaint);
  23.         }
  24.  

The former draws a square behind the ListView.
The latter draws a square before the ListView.
Both move along with scrolling, due to the scrollposition.

I would like to do this in an OnDraw and an OnDispatch of the listview (drawing on the attached Canvas).
These two will also have to transport the scroll-position !
Is this possible ?

Thanks.
Title: Re: Android Module Wizard
Post by: renabor on September 17, 2016, 11:55:21 am
Hi all,

I have uploaded a brand new version of new_howto_install_by_renabor to github.

Please notice that the old new_how_to_install_by_renabor has been converted in several scripts!

Now all you have to do is run first script, "1-master-script.sh", that will call other scripts in the right sequence.

At the end you will have:

1) /etc/fpc.cfg moved to /etc/fpc.cfg.bak and substituted by a symlink
2) ndk, sdk and lamw code placed in a new directory $HOME/Android
3) fpc and lazarus code placed in a new directory $HOME/bin/freepascal
4) a lot of scripts in $HOME/bin/freepascal

and a running compiled full suite of freepascal and lazarus ready to crosscompile to android!

Version of software downloaded:

ndk            android-ndk-r11c-linux-x86_64
sdk            android-sdk_r24.4.1-linux
fpc (fixes)         3.0.1
lazarus          1.7

enjoy!

N.B. There is a bug in lamwdesigner.pas that make compiling problematic.
please change line 58 as
Code: [Select]
//    procedure OnDesignerModified(Sender: TObject{$If lcl_fullversion>1060004}; {%H-}PropName: ShortString{$ENDIF});
procedure OnDesignerModified(Sender: TObject);
and line 1009
Code: [Select]
//procedure TAndroidWidgetMediator.OnDesignerModified(Sender: TObject{$If lcl_fullversion>1060004}; {%H-}PropName: ShortString{$ENDIF});
procedure TAndroidWidgetMediator.OnDesignerModified(Sender: TObject);
Title: Re: Android Module Wizard
Post by: jmpessoa on September 19, 2016, 01:44:18 am
Hi Alfred,

Something like that [??]:

added to "jListView.java"

Code: Java  [Select][+][-]
  1.         @Override
  2.         protected void dispatchDraw(Canvas canvas) {
  3.  
  4.             View c = super.getChildAt(0);
  5.         int scrollposition = -c.getTop() + super.getFirstVisiblePosition() * (c.getHeight()+super.getDividerHeight());                 
  6.                
  7.             //DO YOUR DRAWING ON UNDER THIS VIEWS CHILDREN
  8.                 controls.pOnBeforedispatchDraw(canvas, scrollposition);  //handle by pascal side
  9.                
  10.             super.dispatchDraw(canvas);
  11.            
  12.             //DO YOUR DRAWING ON TOP OF THIS VIEWS CHILDREN
  13.             controls.pOnAfterdispatchDraw(canvas,scrollposition);        //handle by pascal side    
  14.         }
  15.  

So in pascal [event] side we could use the param "canvas" to set "jCanvas"  and then draw some stuff... Something like that?

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jListView1BeforeDispatchDraw(Obj: TObject;
  2.   canvas: JObject; scrollposition: integer);
  3. begin
  4.   jCanvas1.SetCanvas(canvas);
  5.   jCanvas1.drawRect(100, 100, 400, 400);  // Yes!  \o/ \o/ \o/ \o/
  6. end;
  7.  

NOTE: I Got  scrollposition = 0 [always] ....

ref.
http://stackoverflow.com/questions/9655435/custom-listview-drawing
http://stackoverflow.com/questions/16342945/ondraw-bug-on-listview
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 19, 2016, 06:47:57 am
Yes, this would be perfect ! Thanks !!
If you have implemented this, I will investigate/debug the scrollposition problem.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on September 20, 2016, 02:42:49 am
Hi jmpessoa
I am using below components:
java 8 update 101 64 bits
java sdk 8 update 101 32 bits
newest version of lamw
ndk r10e
ant 1.9.7

But when i chose Project > New project and create new one, This alert always appear and i dont know how to fix it
Quote
Error: Access violation
http://imgur.com/a/dMA0D (http://imgur.com/a/dMA0D)

please help. thanks much  :) :)

And in dialog creating new project I see 2 options are armv7 + soft armv7 +Fv3
So which one I should choose , and what are differences ?

Thanks  :) :)
Title: Re: Android Module Wizard
Post by: jmpessoa on September 20, 2016, 06:09:21 am


@Alfred,

Yes,  I implemented...
very soon I will update github repository....
[surely we have to put this feature in others/all components. So, I am thinking/testing about the best strategy...]

@m4u:

The choice depends on how the cross-compiler was built ...
for Laz4Android "armv6"  and "armv7 + soft"   are good!

About "Access violation" I will do some  investigation...
until then, please, update and re-install the 03 LAMW packages...
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on September 20, 2016, 04:44:20 pm


@m4u:

The choice depends on how the cross-compiler was built ...
for Laz4Android "armv6"  and "armv7 + soft"   are good!

About "Access violation" I will do some  investigation...
until then, please, update and re-install the 03 LAMW packages...

i installed lamw, error "Access violation" still appears, but It's a serious problem beacause I can build and run apk file well  :) :)
Hope you will fix this bug soon  :) :)
Title: Re: Android Module Wizard
Post by: A.S. on September 20, 2016, 09:08:35 pm
Hi jmpessoa
I am using below components:
java 8 update 101 64 bits
java sdk 8 update 101 32 bits
newest version of lamw
ndk r10e
ant 1.9.7

But when i chose Project > New project and create new one, This alert always appear and i dont know how to fix it
Quote
Error: Access violation
http://imgur.com/a/dMA0D (http://imgur.com/a/dMA0D)

please help. thanks much  :) :)

And in dialog creating new project I see 2 options are armv7 + soft armv7 +Fv3
So which one I should choose , and what are differences ?

Thanks  :) :)

As far as I know, it is not a good idea to use 64 bit JDK with 32 bit SDK.
You did not mention OS and Lazarus revision you are using.
What exactly did you do to get Access Violation? What kind of project did you choose in "Create a new project dialog"?
I cannot reproduce.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 20, 2016, 09:20:09 pm
Hi Alfred!

OnBeforedispatchDraw and OnAfterdispatchDraw

is Done for jListView/jTextView/jEdtText/jButton

But NOTE: We need a dynamic [and not "harded" code]

LAMW_JAVA_NAMESPACE = 'org.lamw.common';

[Now we have legacy issues with "demos" and old projects!!!]

I wiil fix it!
Title: Re: Android Module Wizard
Post by: DonAlfredo on September 20, 2016, 09:48:26 pm
Thanks !

And , if you want to change the namespace of the common library, just the same as the others, I am also perfectly fine with that ! My commit was just a proposal, open for review. I could also do this for you !

Greetings.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 20, 2016, 10:11:40 pm


OK, Please, do it!

Thank you!


Title: Re: Android Module Wizard
Post by: DonAlfredo on September 20, 2016, 10:20:19 pm
Tomorrow ... now its night-time in Europe ... :-)
Title: Re: Android Module Wizard
Post by: jmpessoa on September 21, 2016, 12:12:51 am

Good dreams! O:-)

The task is done!

Thank  you!

NOTE: Just to simplify codification: "jCommons.java"



Title: Re: Android Module Wizard
Post by: DonAlfredo on September 21, 2016, 11:23:38 am
Thanks again !

Btw, I have done a (rather bad in some places) commit to get some things working, because the two new dispatch methods are not picked up by the java-parser. Must be changed to something better.
On[]Dispatch its rather nice: a standard button with a bitmap is now very easy.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 21, 2016, 09:01:57 pm

Hi Alfred,

The naming:

Code: Java  [Select][+][-]
  1. public native void pOnBeforeDispatchDraw(long pasobj, Canvas canvas, int tag);
  2. public native void pOnAfterDispatchDraw(long pasobj, Canvas canvas, int tag);
  3.  

is OK!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on September 29, 2016, 06:35:50 am

Hi All!

There is a new LAMW revision!

ref.   https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7.4 - 28 September - 2016

   NEW! jUDPSocket component   // <<---  rime's suggestion!

   IMPROVED! jForm: added news methods:
         GetNetworkStatus
         GetDeviceWifiIPAddress
         GetDeviceDataMobileIPAddress
         GetWifiBroadcastIPAddress

   NEW! demo AppUDPSocketDemo1
   NEW! demo AppNumberPickerDemo1

Thanks to All

Title: Re: Android Module Wizard
Post by: dinmil on September 29, 2016, 05:13:31 pm
I tried to build simple GUI application with newest update. I was successful until I put JButton on form. After that I can not build APK.
Even, after I removed button I can not build apk any more. This is the dump. It seems to me that there is an issue with JCommons, and I think this is not only button issue. I think this is an issue with jTextView also.

Messages, Hints: 2
Note: Duplicate unit "controls" in "controls", orphaned ppu "G:\sb\src\branch0650\android\TestHttp\obj\controls\controls.o"
Note: Duplicate unit "controls" in "LCLBase 1.6.0.4", ppu="C:\laz4android\lcl\units\arm-android\controls.ppu", source="C:\laz4android\lcl\controls.pp"
Compile Project, OS: android, CPU: arm, Target: G:\sb\src\branch0650\android\TestHttp\libs\armeabi\libcontrols.so: Success
Building APK... : Exit code 1, Errors: 101
Panic:
Panic: -check-env:
Panic:  [checkenv] Android SDK Tools Revision 25.2.2
Panic:  [checkenv] Installed at C:\Program Files (x86)\Android\android-sdk
Panic:
Panic: -setup:
Panic:      [echo] Project Name: TestHttp
Panic:   [gettype] Project Type: Application
Panic:
Panic: -pre-clean:
Panic:
Panic: clean:
Panic:    [delete] Deleting directory G:\sb\src\branch0650\android\TestHttp\bin
Panic:    [delete] Deleting directory G:\sb\src\branch0650\android\TestHttp\gen
Panic: [getlibpath] Library dependencies:
Panic: [getlibpath] No Libraries
Panic:    [subant] No sub-builds to iterate on
Panic:
Panic: -set-mode-check:
Panic:
Panic: -set-debug-files:
Panic:
Panic: -check-env:
Panic:  [checkenv] Android SDK Tools Revision 25.2.2
Panic:  [checkenv] Installed at C:\Program Files (x86)\Android\android-sdk
Panic:
Panic: -setup:
Panic:      [echo] Project Name: TestHttp
Panic:   [gettype] Project Type: Application
Panic:
Panic: -set-debug-mode:
Panic:
Panic: -debug-obfuscation-check:
Panic:
Panic: -pre-build:
Panic:
Panic: -build-setup:
Panic: [getbuildtools] Using latest Build Tools: 24.0.3
Panic:      [echo] Resolving Build Target for TestHttp...
Panic: [gettarget] Project Target:   Android 5.0.1
Panic: [gettarget] API level:        21
Panic:      [echo] ----------
Panic:      [echo] Creating output directories if needed...
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\bin
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\bin\res
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\bin\rsObj
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\bin\rsLibs
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\gen
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\bin\classes
Panic:     [mkdir] Created dir: G:\sb\src\branch0650\android\TestHttp\bin\dexedLibs
Panic:      [echo] ----------
Panic:      [echo] Resolving Dependencies for TestHttp...
Panic: [dependency] Ordered libraries:
Panic: [dependency]
Panic: [dependency] ------------------
Panic:      [echo] ----------
Panic:      [echo] Building Libraries with 'debug'...
Panic:    [subant] No sub-builds to iterate on
Panic:
Panic: -code-gen:
Panic: [mergemanifest] Merging AndroidManifest files into one.
Panic: [mergemanifest] Manifest merger disabled. Using project manifest only.
Panic:      [echo] Handling aidl files...
Panic:      [aidl] No AIDL files to compile.
Panic:      [echo] ----------
Panic:      [echo] Handling RenderScript files...
Panic:      [echo] ----------
Panic:      [echo] Handling Resources...
Panic:      [aapt] Generating resource IDs...
Panic:      [echo] ----------
Panic:      [echo] Handling BuildConfig class...
Panic: [buildconfig] Generating BuildConfig class.
Panic:
Panic: -pre-compile:
Panic:
Panic: -compile:
Panic:     [javac] Compiling 7 source files to G:\sb\src\branch0650\android\TestHttp\bin\classes
Panic:     [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
Panic:     [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
Panic:     [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Panic:     [javac] G:\sb\src\branch0650\android\TestHttp\src\org\lamw\testhttp\jButton.java:16: error: cannot find symbol
Panic:     [javac]    private jCommons LAMWCommon;
Panic:     [javac]            ^
Panic:     [javac]   symbol:   class jCommons
Panic:     [javac]   location: class jButton
Panic:     [javac] G:\sb\src\branch0650\android\TestHttp\src\org\lamw\testhttp\jButton.java:29: error: cannot find symbol
Panic:     [javac]       LAMWCommon = new jCommons(this,context,pasobj);
Panic:     [javac]                        ^
Panic:     [javac]   symbol:   class jCommons
Panic:     [javac]   location: class jButton
Panic:     [javac] Note: G:\sb\src\branch0650\android\TestHttp\src\org\lamw\testhttp\Controls.java uses or overrides a deprecated API.
Panic:     [javac] Note: Recompile with -Xlint:deprecation for details.
Panic:     [javac] 2 errors
Panic:     [javac] 3 warnings
Panic:
Panic: BUILD FAILED
Panic: C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
Panic: C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.
Panic:
Panic: Total time: 1 second
Panic: tool stopped with exit code 1. Use context menu to get more information.
Exception, Errors: 1
Fatal: [Exception] Failed: Cannot build APK!
Title: Re: Android Module Wizard
Post by: jmpessoa on September 29, 2016, 08:11:06 pm


Hi dinmil

Please, update your project java stuff.... [close and reopen and try "Run"]

jListView, jTextView, jEditText and jButton  are now in "jCommons.java" compliance.

Try 1: "Run"--> "Clean up and Build"

Try 2. Des-Install an re-install all 03 lamw package:

.uninstall [amw_ide_tools.lpk]
.uninstall [lazandroidwizardpack.lpk]
.uninstall [tfpandroidbridge_pack.lpk]   // <--- uninstall at last!

RE- INSTALL:

          [tfpandroidbridge_pack.lpk] // <<-- install first
      [lazandroidwizardpack.lpk]
      [amw_ide_tools.lpk]

NOTE: In fact the update should be automatically...
please,  set "CanUpdateJavaTemplate=t"  in
"lazarus\config\JNIAndroidProject.ini"
Title: Re: Android Module Wizard
Post by: dinmil on September 30, 2016, 10:35:05 am
Thanks for quick response.
Re installation of components and install didn't hep.
Cleanup and build did not help.

But settin "CanUpdateJavaTemplate=t"  in "lazarus\config\JNIAndroidProject.ini" did the job.

I detect one more issue.
If you try to put jAutoTextView on form you will get access violation

Regards, Dinko

Title: Re: Android Module Wizard
Post by: jmpessoa on October 02, 2016, 03:34:52 pm

Hi dinmil,

About:
Quote
If you try to put jAutoTextView on form you will get access violation...

Fixed! Please, try/test again.

Thank you!
Title: Re: Android Module Wizard
Post by: dinmil on October 03, 2016, 09:39:44 am
Just downloaded new version (zip file) from GIT HUB.
Removed old packages. Install new ones. Rebuild laz4android with clean all option.
This Access Violation error still exists when you put JAutoTextView on form.

Regards, Dinko
Title: Re: Android Module Wizard
Post by: jmpessoa on October 03, 2016, 10:01:36 am
Please try this:

Code: Pascal  [Select][+][-]
  1. procedure jAutoTextView.SetItems(AValue: TStrings);
  2. begin
  3.    if AValue <> nil then     // <<---- added here....
  4.        FItems.Assign(AValue);
  5. end;
  6.  

NOTE 1: I do not have/detect any problem with jAutoTextView....

Note 2: You got A.V in design time?
Title: Re: Android Module Wizard
Post by: dinmil on October 03, 2016, 10:35:35 am

I added this line into autocompletetextview.pas. Build and recompile lazarus. Same situation (see Picture1)

Steps to reproduce.

I started new project Android GUI JNI MODULE LAMW.
After trying to add JAutoTextView one time, I choose OK in access violation dialog, then I tried to add new one.
After that I got again access vilation and again choose OK. After that 2 JAutoTextView control shows on form.
Then I try to add third one. This time no problem and no access violation.

Regards, Dinko

Title: Re: Android Module Wizard
Post by: jmpessoa on October 03, 2016, 08:45:22 pm

I will continue investigating .... repeating its sequence everything goes well..

Code: Pascal  [Select][+][-]
  1. constructor jAutoTextView.Create(AOwner: TComponent);
  2. begin
  3.   inherited Create(AOwner);
  4.  
  5.   //.....................................................
  6.  
  7.   FItems:= TStringList.Create;  //potential error should be here [when forgotten!]
  8.  
  9.   //.......................................................
  10.  
  11.  
  12. end;
  13.  
Title: Re: Android Module Wizard
Post by: A.S. on October 03, 2016, 11:22:00 pm
dinmil, what Lazarus IDE revision do you use?
Title: Re: Android Module Wizard
Post by: dinmil on October 04, 2016, 04:41:30 pm
This is Laz4Andorid.
SVN 51630
Title: Re: Android Module Wizard
Post by: A.S. on October 04, 2016, 09:38:57 pm
This is Laz4Andorid.
SVN 51630
Cannot reproduce.
What Android SDK and Android theme settings do you use?
Title: Re: Android Module Wizard
Post by: dinmil on October 05, 2016, 11:44:55 am
Android SDK Manager
Revision 25.2.2

Java is jdk1.8.0_102

Android Theme is DeviceDefault

Architecture ARMv6 (ARM v7 has the same behavior)

Regards, Dinko


Title: Re: Android Module Wizard
Post by: A.S. on October 05, 2016, 08:39:28 pm
Dinko, what Android SDK do you use? Not the version of the Android SDM Manager, but what Android API? (Android 7.0 is API 24)
Title: Re: Android Module Wizard
Post by: dinmil on October 06, 2016, 01:36:52 pm
NdkPlatform is 21
MinSDKApi is 15
TargetSdkApi is 21 (tried all from 15, 21, 22, 23, 24 - no success, only 19 is OK)

NdkPlatform is 15
MinSDKApi is 15
TargetSdkApi is 15 (tried 19=OK; 21=not OK)

NdkPlatform is 16, 17, 18, 19, 21
MinSDKApi is 15
TargetSdkApi is 19 (OK)

It seems that this error depends of combination Ndk and TargetSdk

Thanks for hint, Dinko





Title: Re: Android Module Wizard
Post by: greenzyzyzy on October 11, 2016, 04:50:13 pm
does Android Module Wizard can use the android api like below?
here codes is from http://wiki.lazarus.freepascal.org/Android_Programming
uses jni, customdrawnint;
 
var
  javaClass_HttpGet, javaClass_URI: jclass;
  javaMethod_HttpGet_new, javaMethod_HttpGet_setURI,
    javaMethod_URI_new: jmethodid;
  javaRequest, javaURI: jobject;
  javaString: jstring;
  lParams: array[0..2] of JValue;
  lNativeString: PChar;
begin
  DebugLn(':>LoadHTMLPageViaJNI');
  // First call FindClass for all required classes
  javaClass_HttpGet := javaEnvRef^^.FindClass(javaEnvRef,
    'org/apache/http/client/methods/HttpGet');
  javaClass_URI := javaEnvRef^^.FindClass(javaEnvRef,
    'java/net/URI');
Title: Re: Android Module Wizard
Post by: Leledumbo on October 11, 2016, 07:18:05 pm
does Android Module Wizard can use the android api like below?
tfpandroidbridge_pack package has and_jni unit which similarly wraps jni as jni unit does. Most of the unit contents are the same, only jmpessoa add little additions, everything else should remain the same. javaEnvRef is defined in customdrawnint unit, so you can't use that if you use LAMW. LAWM equivalent of it is AndroidWidget.gApp.Jni.jEnv.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 12, 2016, 09:06:06 am
Hi  greenzyzyzy!

LAMW leaves you free to play with the JNI world!

Got to demo "AppTest2" .... 

You can create a new/dynamic button in the hard way!
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton4Click(Sender: TObject);
  2. var
  3.   jParamsString:array[0..1] of jValue;
  4.  
  5.   jParamsId: array[0..0] of jValue;
  6.   jParamsColor: array[0..0] of jValue;
  7.  
  8.   jParamsContext:array[0..0] of jValue;
  9.   jParamsInt:array[0..1] of jValue;
  10.  
  11.   jParamsPosRelativeToParent: array[0..0] of jValue;
  12.   jParamsPosRelativeToAnchor: array[0..1] of jValue;
  13.  
  14.   jParamsLayout: array[0..0] of jValue;
  15.   jParamsButton:array[0..0] of jValue;
  16.   jParamsListener: array[0..0] of jValue;
  17.  
  18.   jClass_button: jClass;
  19.   jClass_Param: jClass;
  20.   jClass_viewgroup: jClass;
  21.   jClass_view: jClass;
  22.  
  23.   jMethodId_setText: jMethodID; //not is an object reference!
  24.   jMethodId_setTextColor: jMethodID;
  25.   jMethodId_setId: jMethodID;
  26.  
  27.   jMethodId_setLayoutParams: jMethodID;
  28.   jMethodId_addRule: jMethodID;
  29.   jMethodId_addRuleAnchor: jMethodID;
  30.   jMethodId_getId: jMethodID;
  31.  
  32.   jMethodId_addView: jMethodID;
  33.   jMethodId_setOnClickListener: jMethodID;
  34.  
  35.   jObj_layoutParams: jObject;
  36.   jObj_button: jObject;
  37.   anchorID: integer;
  38.   list: array of string;
  39.   customColor: DWord;
  40. begin
  41.  
  42.    customColor:= $FF2C2F3E;
  43.  
  44.    jParamsContext[0].l:= gApp.GetContext; //get Activity/Context object
  45.  
  46.    //get class button
  47.    jClass_button:= Get_jClassLocalRef('android/widget/Button');
  48.  
  49.    //create object button ::class ref,param signature, param
  50.    jObj_button:=Create_jObjectLocalRefA(jClass_button, 'Landroid/content/Context;', jParamsContext);
  51.  
  52.    //get method :: class ref, method name, (param segnature)return type
  53.    jMethodId_setText:= Get_jMethodID(jClass_button, 'setText','(Ljava/lang/CharSequence;)V');
  54.    jParamsString[0].l:= Get_jString('Button 1!'); //result is object!
  55.    Call_jVoidMethodA(jObj_button, jMethodId_setText, jParamsString);
  56.    Delete_jLocalParamRef(jParamsString, 0 {index});  //just cleanup...
  57.  
  58.  
  59.    //set sTextColor
  60.    jMethodId_setTextColor:= Get_jMethodID(jClass_button, 'setTextColor','(I)V');
  61.    jParamsColor[0].i:= GetARGB(customColor, colbrPaleGreen); // integer ..
  62.    Call_jVoidMethodA(jObj_button, jMethodId_setTextColor, jParamsColor);
  63.  
  64.    //get method  setId
  65.    jMethodId_setId:= Get_jMethodID(jClass_button, 'setId','(I)V');
  66.    jParamsId[0].i:= 1001;
  67.    Call_jVoidMethodA(jObj_button, jMethodId_setId, jParamsId);
  68.  
  69.    //create object LayoutParam and addRule
  70.    jParamsInt[0].i:= GetLayoutParams(gApp, lpHalfOfParent {lpMatchParent}, sdW);  //W
  71.    jParamsInt[1].i:= GetLayoutParams(gApp, lpWrapContent, sdH);  //H
  72.  
  73.    jClass_Param:= Get_jClassLocalRef('android/widget/RelativeLayout$LayoutParams');
  74.    jObj_layoutParams:= Create_jObjectLocalRefA(jClass_Param,'II', jParamsInt);  //create an empty string!
  75.  
  76.    jMethodId_addRule:= Get_jMethodID(jClass_param, 'addRule','(I)V');
  77.  
  78.    jParamsPosRelativeToParent[0].i:= GetPositionRelativeToParent(rpLeft{rpCenterHorizontal});  //a rule ...
  79.    Call_jVoidMethodA(jObj_layoutParams, jMethodId_addRule, jParamsPosRelativeToParent); //set center horiz
  80.  
  81.    //jParamsPosRelativeToParent[0].i:= GetPositionRelativeToParent(rpBottom);  //other rule ...
  82.    //Call_jVoidMethodA(jObj_layoutParams, jMethodId_addRule, jParamsPosRelativeToParent);
  83.  
  84.    //Set anchor object ...
  85.    jClass_view:= Get_jClassLocalRef('android/view/View');
  86.    jMethodId_getId:= Get_jMethodID({jClass_button}jClass_view , 'getId','()I');
  87.    anchorId:= Call_jIntMethod(jButton4.jSelf, jMethodId_getId); //choice jButton4 as anchor ...
  88.    if anchorId <= 0 then
  89.    begin
  90.      anchorId:=  9999;
  91.      jMethodId_setId:= Get_jMethodID({jClass_button} jClass_view, 'setId','(I)V');
  92.      jParamsId[0].i:= anchorId;
  93.      Call_jVoidMethodA(jButton4.jSelf, jMethodId_setId, jParamsId);
  94.    end;
  95.    jParamsPosRelativeToAnchor[0].i:= GetPositionRelativeToAnchor(raBelow);  //set below  jButton4
  96.    jParamsPosRelativeToAnchor[1].i:= anchorId;
  97.    jMethodId_addRuleAnchor:= Get_jMethodID(jClass_param, 'addRule','(II)V'); //rule and anchorID
  98.    Call_jVoidMethodA(jObj_layoutParams, jMethodId_addRuleAnchor, jParamsPosRelativeToAnchor);
  99.  
  100.    Delete_jLocalRef(jClass_Param);
  101.  
  102.    //get setLayoutParams from class Button
  103.    jMethodId_setLayoutParams:= Get_jMethodID(jClass_button, 'setLayoutParams','(Landroid/view/ViewGroup$LayoutParams;)V');
  104.    jParamsLayout[0].l:= jObj_layoutParams;
  105.    Call_jVoidMethodA(jObj_button, jMethodId_setLayoutParams, jParamsLayout); //setLayoutParams(jObj_layoutParams)
  106.  
  107.  
  108.    //get setOnClickListener from class Button
  109.    jParamsListener[0].l:=  Self.GetOnViewClickListener(Self.jSelf); //or Self.OnClickListener; //or gApp.GetClickListener;
  110.    jMethodId_setOnClickListener:= Get_jMethodID(jClass_button, 'setOnClickListener','(Landroid/view/View$OnClickListener;)V');
  111.    Call_jVoidMethodA(jObj_button, jMethodId_setOnClickListener, jParamsListener); //jMethodId_setOnClickListener(...)
  112.  
  113.  
  114.    //get "addView" from android.view.ViewGroup
  115.    jClass_viewgroup:= Get_jClassLocalRef('android/view/ViewGroup');
  116.    jMethodId_addView:= Get_jMethodID(jClass_viewgroup, 'addView','(Landroid/view/View;)V');
  117.    Delete_jLocalRef(jClass_viewgroup);
  118.  
  119.    jParamsButton[0].l:=  jObj_button;
  120.    Call_jVoidMethodA(Self.View {theform view!}, jMethodId_addView, jParamsButton); // addView(jObj_button)
  121.  
  122.    Delete_jLocalRef(jParamsLayout[0].l); //just cleanup...
  123.    //or: Delete_jLocalRef(jObj_param);
  124.  
  125.    Delete_jLocalRef(jObj_button);
  126.    //or Delete_jLocalRef(jParamsButton[0].l); //just cleanup...
  127.  
  128. end;
  129.  

and "Laz_And_jni_Controls.pas" present a new design/concept for LAMW component model!

You can create a new/dynamic  "TAndroidListView":
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton5Click(Sender: TObject);
  2. var
  3.   my_jObj: TAndroidListView;
  4.   arrayStringsItems: array of string;
  5.   jStringListAdapter: jObject;
  6. begin
  7.  
  8.   SetLength(arrayStringsItems, 4);
  9.  
  10.   arrayStringsItems[0]:= 'Item 0';
  11.   arrayStringsItems[1]:= 'Item 1';
  12.   arrayStringsItems[2]:= 'Item 2';
  13.   arrayStringsItems[3]:= 'Item 3';
  14.  
  15.   my_jObj:= TAndroidListView.Create(Self);
  16.   my_jObj.LayoutParamWidth:= lpMatchParent; //lpHalfOfParent;   //try this!
  17.   my_jObj.LayoutParamHeight:= lpWrapContent;
  18.  
  19.   my_jObj.Init(gApp);
  20.  
  21.   jStringListAdapter:= my_jObj.GetStringListAdapter(arrayStringsItems);
  22.  
  23.   my_jObj.SetArrayAdapter(jStringListAdapter);
  24.  
  25.   my_jObj.AddStringToListAdapter(jStringListAdapter, 'Hello');
  26.  
  27.   my_jObj.NotifyDataSetChanged(jStringListAdapter);
  28.  
  29.   //my_jObj.Text:= 'Button 1!';
  30.   //my_jObj.SetTextColor(GetARGB(colbrPaleGreen));
  31.  
  32.   my_jObj.BackgroundColor:= colbrPaleGreen;
  33.  
  34.   my_jObj.Id:= 2001;
  35.  
  36.   my_jObj.AddParentRule(GetPositionRelativeToParent(rpCenterHorizontal{rpRight}));
  37.  
  38.    //my_jObj.AddParentRule(GetPositionRelativeToParent(rpBottom));
  39.  
  40.   my_jObj.AddAnchorRule(GetPositionRelativeToAnchor(raBelow), jButton4.jSelf);
  41.  
  42.   my_jObj.AddToView(Self.View);
  43.  
  44.   my_jObj.SetOnItemClickListener(Self.GetOnListItemClickListener(Self.jSelf));
  45.  
  46. end;
  47.  
  48.  

Enjoy!

NOTE:  LAMW "Get_jClassLocalRef" is a wrapper to JNI interface code:
Code: [Select]
FindClass:function(Env:PJNIEnv;const Name:pchar):JClass;{$ifdef mswindows}stdcall;{$else}cdecl;{$endif}

etc...

Title: Re: Android Module Wizard
Post by: greenzyzyzy on October 15, 2016, 02:35:44 pm
does lamw can use java api directly which just like use windows api now?
Title: Re: Android Module Wizard
Post by: Thaddy on October 15, 2016, 03:08:16 pm
Yes, but the naming convention is different for fpc jvm. This is clearly documented in the wiki.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 15, 2016, 09:01:37 pm
Quote
does lamw can use java api directly which just like use windows api now?

LAMW is JNI based.

About JNI:
Quote
.A specification/protocol for calling 'native' code from Java and Java code from native applications ('Invocation API');

.An interface that allows Java to interact with code written in another language:  The Java  code can invoke native methods;

.An interface that allows code written in another language to interact with Java : The native code can instantiate Java objects and invoke methods;

.JNI is about "Programming for the Java Virtual Machine";

.JNI is used  to interact with "native" code produced by system-level language like C/C++ and Pascal/Object Pascal!
Title: Re: Android Module Wizard
Post by: renabor on October 29, 2016, 05:59:56 pm
Hello @jmpessoa!

I got this new, strange error running my app:

Code: [Select]
E/art: dlopen("/data/app/com.suevoz.borsa-1/lib/arm/libcontrols.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "U_$CONTROLS_$$_MOUSE" referenced by "libcontrols.so"...
E/JNI_Load_LibControls: exception
                        java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "U_$CONTROLS_$$_MOUSE" referenced by "libcontrols.so"...

have you any idea what does it mean?

thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on November 24, 2016, 02:21:38 am
Hi, All!

Inspired by @tk's works...

Added LAMW  support to build custom library!

NEW: LAMW IDE Tools "Import C Stuff"
NEW: LAMW Console App -->> checkbox "Library"
[Linux: need add "h2pas" to folder "ide_tools"]

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!

EDITED.  Thanks to @Renabor.
Title: Re: Android Module Wizard
Post by: renabor on November 25, 2016, 04:39:18 pm

Hi, All!

Inspired by @tk's works...

Added LAMW  support to build custom library!

NEW: LAMW IDE Tools "Import C Stuff"
NEW: LAMW Console App chebox "Library"
[Linux: need add "ht2pas" to folder "ide_tools"]

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Thanks to All!

What is "ht2pas" and where can I find it?
Thank you!

Found! h2pas (not ht2pas) in fpc/bin !
Title: Re: Android Module Wizard
Post by: jmpessoa on November 25, 2016, 05:16:05 pm
Quote
Found! h2pas (not ht2pas) in fpc/bin !

Yes! Please, send me your linux "h2pas" [32 bits] or
put it in LAMW github [folder "ide_tools"].

NOTE 1: About "Import C Stuff".

Open a LAMW project,  go to LAMW "Import C Stuff". LAMW will
produce a library [*.so] and put it in the same folder of "controls.so".
Then "h2pas" will produce a header conversion (*.pp) for each ".h"  and put it in  folder   "..../jni".  Add the "*.pp" stuff to "uses" section and.... have fun! 

NOTE 2. There is some issue/bug with  Android < 4.1 (already explained here in the forum by @yury_sidorov). So stay with 4.1+.
Title: Re: Android Module Wizard
Post by: renabor on November 25, 2016, 06:19:15 pm
Quote
Found! h2pas (not ht2pas) in fpc/bin !

Yes! Please, send me your linux "h2pas" [32 bits] or
put it in LAMW github [folder "ide_tools"].

I have put a link in ide_tools pointing to fpc_src_dir/bin/h2pas and I think it is a better choice. What can succeed if version of h2pas provided is not compatible with fpc version installed?
Automating the link creation could be a good solution in my advice
Title: Re: Android Module Wizard
Post by: spiritt on November 30, 2016, 01:31:35 pm
Hello everyone!

Can anyone tell me, why using block in LAMW:

try
   ...
   try
       ...
   except
   ...
finally
   ...
end;

doesn't work !? Any suggestions?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 30, 2016, 03:44:25 pm

Hello   spiritt!

From demo "AppPascalLibExceptionHandlerDemo1"

procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  i: integer;
begin
  try
    i:= StrToInt('p');   // some erroneous code
  except
    on E: Exception do ShowMessage(Self.DumpExceptionCallStack(E));  //Thanks to Euller and Oswaldo!
  end;
end;
Title: Re: Android Module Wizard
Post by: spiritt on December 17, 2016, 10:38:31 pm
Ok, thank You for Your quick response:) However it doesn't work good as well...

I put those lines below to mentioned project:

var
  tf: TextFile;
begin
    try
      AssignFile(tf, '\\');
      Append(tf);
      Writeln(tf, 'Test');
      // some erroneous code
      //    i:= StrToInt('p');
  except
    on E: Exception do ShowMessage(Self.DumpExceptionCallStack(E));  //Thanks to Euller and Oswaldo!
  end;
  CloseFile(tf);
end;

...and as the result the app closed. Any other tip? Thank You in advance  :D
Title: Re: Android Module Wizard
Post by: jmpessoa on January 28, 2017, 10:36:57 pm


Hi All!

There are some news in LAMW repository!

ref.
https://github.com/jmpessoa/lazandroidmodulewizard

   NEW! jOpenDialog component   [thanks to @majid.ebru's suggestion!]
   NEW! demo AppOpenFileDialogDemo1

   IMPROVED! jForm: added news methods:  [thanks to @Fatih !]
      GetAssetContentList
      GetDriverList
      GetFolderList
      GetFileList

   NEW! jFileProvider component
   NEW! demo AppFileProviderDemo1   <-- Run First!!
   NEW! demo AppFileProviderClientDemo1

And many, many infrastructure improvements [thanks to @A.S !]

Thanks to All!
Title: Re: Android Module Wizard
Post by: jmpessoa on February 18, 2017, 05:20:49 pm

Hi All!

There is an updated LAMW revision!

ref https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7.11 - 17 - Feb - 2017

   NEW! jWindowManager component

   NEW! demo AppWindowManagerDemo1
      [floating and draggable View!]

   IMPROVED!
      jForm: news methods:
         Minimize
         Restart

      jButton: news methods
         SetCompoundDrawables
         SetRoundCorner
         SetRadiusRoundCorner

      jTextView: news methods
         SetCompoundDrawables
         SetRoundCorner
         SetRadiusRoundCorner

      jRadioGroup: news methods
         SetRoundCorner
         SetRadiusRoundCorner
         
      jPanel:: news methods
         SetRoundCorner
         SetRadiusRoundCorner

      jImageView: news methods      
         SetRoundCorner
         SetRadiusRoundCorner

      jEditText: news method
         SetCompoundDrawables

      jCheckBox: news method
         SetCompoundDrawables

      jRadioButton: news method
         SetCompoundDrawables            


Thanks to All!

PS.
Hi @majid.ebru the "AppLocationDemo1" was updated!
Title: Re: Android Module Wizard
Post by: majid.ebru on February 19, 2017, 12:52:56 pm
thank you very Mr.jmpessoa


Hi All!

There is an updated LAMW revision!

ref https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7.11 - 17 - Feb - 2017

   NEW! jWindowManager component

   NEW! demo AppWindowManagerDemo1
      [floating and draggable View!]

   IMPROVED!
      jForm: news methods:
         Minimize
         Restart

      jButton: news methods
         SetCompoundDrawables
         SetRoundCorner
         SetRadiusRoundCorner

      jTextView: news methods
         SetCompoundDrawables
         SetRoundCorner
         SetRadiusRoundCorner

      jRadioGroup: news methods
         SetRoundCorner
         SetRadiusRoundCorner
         
      jPanel:: news methods
         SetRoundCorner
         SetRadiusRoundCorner

      jImageView: news methods      
         SetRoundCorner
         SetRadiusRoundCorner

      jEditText: news method
         SetCompoundDrawables

      jCheckBox: news method
         SetCompoundDrawables

      jRadioButton: news method
         SetCompoundDrawables            


Thanks to All!

PS.
Hi @majid.ebru the "AppLocationDemo1" was updated!
Title: Re: Android Module Wizard
Post by: renabor on February 24, 2017, 05:55:11 pm
Hello @jmpessoa!
great work on new version!
For next releases, can you (not only you, off course), please, avoid to add and remove randomly spaces in front of lines?
Indeed comparing versions of such files is very frustrating
thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on February 27, 2017, 05:48:28 pm

Hi, All!

There is a new LAMW revision!

ref.

https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7.13 - 27 - Feb - 2017

   NEW! jMaps component  [A wrapper to run google app "Maps"]

   NEW! demo AppMapsDemo1

   REFACTORING!
      All java tamplates are now in compliance with @DonAlfredo's "jCommons.java"
      and [try] SDK API >= 13 compatible [thanks to @tk]
Title: Re: Android Module Wizard
Post by: renabor on March 03, 2017, 11:10:55 am
Hello @jmpessoa!

after last commit to github, changes made to Java_Event_pOnDraw make it impossible to build without errors.
Error message is:

Code: [Select]
controls.lpr(564,1) Error: Wrong number of parameters specified for call to "Java_Event_pOnDraw"

can you please correct it?
Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 03, 2017, 05:11:03 pm


Yes, OnDraw signature changed   [lost the parameter jCanvas]! [sorry....]

Please, update your "Controls.native" and your
event handler code.... [now we need just set the property "canvas"
in design time]



Title: Re: Android Module Wizard
Post by: renabor on March 03, 2017, 05:31:35 pm
Yes, OnDraw signature changed   [lost the parameter jCanvas]! [sorry....]

Please, update your "Controls.native" and your
event handler code.... [now we need just set the property "canvas"
in design time]

... there was it, in Controls.native!
thank you!
Title: Re: Android Module Wizard
Post by: vfclists on March 03, 2017, 05:37:07 pm
What Lazarus created android programs can I try on my phone?
Title: Re: Android Module Wizard
Post by: jmpessoa on March 03, 2017, 08:57:13 pm


Yes!
After install LAMW packages you will get a new Lazarus menu  option:
"Run" ---> "[Lamw]Build Android Apk and Run"

You can read from here: "readme_get_start.txt"


Title: Re: Android Module Wizard
Post by: ketch on March 05, 2017, 02:28:25 pm
Hello jmpessoa,

Lamw works great with fpc 3.0.0 and lazarus 1.6.2.
I use the last lamw 0.7.13 and it is a great work!

Some times ago a make a test with fpc 3.0.2 and lazarus 1.6.2 and sample apps crash at startup on the android device.
I wait for the lazarus update, but with fpc 3.0.2 and the new lazarus 1.6.4 apps crash to at startup on the android device.

Is it normal, or maybe i make something wrong ?
Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 05, 2017, 03:24:59 pm

Hello ketch!

1.Sometimes any modification or update can affect some [outdated] demo application.... what app you have tested?

2. If you change your FPC revision then you need to do a "Run"-->"Clean up and Build" before "[Lamw] "Build Android Apk and Run"
Title: Re: Android Module Wizard
Post by: ketch on March 05, 2017, 08:55:09 pm
I have give a try to a lot of random sample and i dont remenber all. :(
I have fpc 3.0.0 and lazarus 1.6.2 reinstalled and can't retry now.
What i can say is that the AppActionBarTabDemo1 for example doesn't work for me and i have make a clean new install after deleting old directory (new fpc, new lazarus and new lamw)...
After executing exactly the same process for go back to fpc 3.0.0 and lazarus 1.6.2 all works great.
Title: Re: Android Module Wizard
Post by: ketch on March 06, 2017, 08:34:16 pm
Hello jmpessoa,

today i make a new try with fpc 3.0.2 and lazarus 1.6.4 (total reinstallation) and i dont find any working sample application.
I reinstall fpc 3.0.0 and keep lazarus 1.6.4 and the majority of sample are working.
It seem that fpc 3.0.2 is the problem.
Is someone using the fpc version 3.0.2 and can confirm there is no problem with this version.

Thank you.
Title: Re: Android Module Wizard
Post by: renabor on March 07, 2017, 09:34:53 am
Hello @jmpessoa!

I get a new error, realtoed to pAppOnScreenStyle, starting the app:

Code: [Select]
java.lang.UnsatisfiedLinkError: No implementation found for int com.suevoz.borsa.Controls.pAppOnScreenStyle() (tried Java_com_suevoz_borsa_Controls_pAppOnScreenStyle and Java_com_suevoz_borsa_Controls_pAppOnScreenStyle__)
                      at com.suevoz.borsa.Controls.pAppOnScreenStyle(Native Method)
                      at com.suevoz.borsa.Controls.jAppOnScreenStyle(Controls.java:1258)
                      at com.suevoz.borsa.App.onCreate(App.java:63)

any idea on what happened?
Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 07, 2017, 04:07:50 pm

Maybe the error can be in another [start] place....
Have you some jImageList component? If yes, put a new [dummy] jImageList in form... save all.... now delete the dummy....
So your project has been updated! [jImageList now need a "jImageList.java"  template....]
Title: Re: Android Module Wizard
Post by: renabor on March 07, 2017, 04:32:25 pm

Maybe the error can be in another [start] place....
Have you some jImageList component? If yes, put a new [dummy] jImageList in form... save all.... now delete the dummy....
So your project has been updated! [jImageList now need a "jImageList.java"  template....]

No, I don't use jImageList. Anyway, if you mean the .create files, where must I put them?
I copy the .native needed files in /lamwdesigner/, but what have I to do with .create ?

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 07, 2017, 04:57:28 pm

You do not need handle the ".create" or ".native"  for the components.... the form wizard  will take care of this...
What about create a new [test] project .... So you will understand the
new "smartdesigner" ..... and where is handled this stuff...
Title: Re: Android Module Wizard
Post by: renabor on March 07, 2017, 05:28:48 pm

You do not need handle the ".create" or ".native"  for the components.... the form wizard  will take care of this...
What about create a new [test] project .... So you will understand the
new "smartdesigner" ..... and where is handled this stuff...

What I have understood is that the .native code is copied at the end of Controls.java, when a new component is added to the form. No idea of the purpose of .create file.
At the very first time of the new "smartdesign" era, Controls.java was copied every time from lamw directory to project directory.
Now something is changed, because I guess that Controls.java is recreated on-site, even if I have:

Code: [Select]
CanUpdateJavaTemplate = "True".

Am I right?
thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on March 07, 2017, 08:09:24 pm

1. "Controls.java" + "Controls.native" + "jCommons.java"are default for all initial project  [like an "empty" form]

2. Every [almost] component has a ".java" and a ".create" and [optional]  a ".native" and [optional] etc ...

3. When you drag&drop a jComponent, over the form,  the "jComponent.java" is inserted in your project ".../scr/...." and the component ".create" and ".native"  are added at the end of "Controls.java"

4.The "smartdesigner" use these information to generate a custom ".lpr" whenever a "save all" occur...
Title: Re: Android Module Wizard
Post by: renabor on March 08, 2017, 09:11:32 am

1. "Controls.java" + "Controls.native" + "jCommons.java"are default for all initial project  [like an "empty" form]

2. Every [almost] component has a ".java" and a ".create" and [optional]  a ".native" and [optional] etc ...

3. When you drag&drop a jComponent, over the form,  the "jComponent.java" is inserted in your project ".../scr/...." and the component ".create" and ".native"  are added at the end of "Controls.java"

4.The "smartdesigner" use these information to generate a custom ".lpr" whenever a "save all" occur...

Good to know!
I have purged and reassembled Controls.java adhering to the new design, but I get the same error:

Code: [Select]
java.lang.UnsatisfiedLinkError: No implementation found for int com.suevoz.borsa.Controls.pAppOnScreenStyle() (tried Java_com_suevoz_borsa_Controls_pAppOnScreenStyle and Java_com_suevoz_borsa_Controls_pAppOnScreenStyle__)

I think that something in an extra file is not updated, some file like ControlsEvents.txt

in controls.lpr the method is defined as:
Code: [Select]
{ Class:     com_suevoz_borsa_Controls
  Method:    pAppOnScreenStyle
  Signature: ()I }
function pAppOnScreenStyle(PEnv: PJNIEnv; this: JObject): JInt; cdecl;
begin
  Result := Java_Event_pAppOnScreenStyle(PEnv, this);
end;

is this correct?

Thank you!

Title: Re: Android Module Wizard
Post by: jmpessoa on March 08, 2017, 11:09:37 pm

Yes, this is correct!

You can see  in "Laz_And_Controls.pas"  //in line 1617

Code: Pascal  [Select][+][-]
  1.   // ----------------------------------------------------------------------------
  2.   //  Event Handler  : Java -> Pascal
  3.   // ----------------------------------------------------------------------------
  4.  
  5.   // Activity Event
  6.   Function  Java_Event_pAppOnScreenStyle         (env: PJNIEnv; this: jobject): JInt;  
  7.  

So I continue to think that these errors are due to some inconsistency in the structure of your project...
Did you try some "new" project? what about?

Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on March 18, 2017, 02:21:41 pm
I meet this error and I read about your exlain how to fix
controls.lpr(564,1) Error: Wrong number of parameters specified for call to "Java_Event_pOnDraw"

I added parameter "jcanvas" in line has "ondraw" file controls.native
but it still be wrong
:(
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on March 18, 2017, 03:15:15 pm
 :( Now If I create new project, and empty form ( form doesnt have any controls component on ) and build-run, all ok
But for example, when I drop and drag some controls, as button and tedit then build-run, below errors appear
see image: http://imgur.com/a/qcMRj


 :( :( :( :( :(
Title: Re: Android Module Wizard
Post by: jmpessoa on March 18, 2017, 05:13:11 pm
Hi m4u!

Please,  don't hack/change "controls.native" ....  indeed
"OnDraw" signature lost the "jCanvas" parameter [sorry] .... you need only change/adapt your app code...
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on March 24, 2017, 05:00:21 pm
@jmpessoa
Now my min api is 15 and target api max is 22
so can my app be run on newer version of android ? , such as android 6++ ?
if cant, how to change target api for that ?
thanks :)
Title: Re: Android Module Wizard
Post by: jmpessoa on March 25, 2017, 03:25:45 am

Quote
...so can my app be run on newer version of android ?

Yes!
Title: Re: Android Module Wizard
Post by: jt2003 on March 25, 2017, 03:13:04 pm
Error Trying to install version 0.7.14 - Package TFPandroidbridge_pack : cannot find textureview ....

Windows 10 64 bits
what could it be?
thanks,
Title: Re: Android Module Wizard
Post by: jmpessoa on March 25, 2017, 04:50:40 pm

Sorry... I will fix it just now!

Thank you!
Title: Re: Android Module Wizard
Post by: jt2003 on March 25, 2017, 05:02:54 pm
Obrigado João!  ::)

Thanks a lot!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 25, 2017, 05:45:56 pm

Hi All!

there is a new LAMW revision!

Version 0.7.14 - 24 - March - 2017  [Fixed! thanks to jt2003]

   NEW! jVideoView component

   NEW! demo AppVideoViewDemo1

   IMPROVED!
      jNotificationManager   --- thanks to majid.ebru!

   NEW! demo AppNotificationManagerDemo2

   UPDATED! demo AppNotificationManagerDemo1 --- thanks to majid.ebru!

   IMPROVED!
      jTextView: news methods
         SetFontFromAssets  --- thanks to majid.ebru!
         SetTextIsSelectable
         SetScrollingText
         SetTextAsLink   
         
      jEditText:: new method
         SetFontFromAssets 

      jButton: new method 
         SetFontFromAssets

      jCheckBox: new method 
         SetFontFromAssets

      jRadioButton: new method
         SetFontFromAssets

   NEW! demo AppCustomFontDemo1   --- thanks to majid.ebru!
Title: Re: Android Module Wizard
Post by: liyuangarcia on March 29, 2017, 09:23:44 pm
I have an error while build the APK

Buildfile: D:\App\LamwGUIProject2\build.xml




-set-mode-check:



-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.4.1
 [checkenv] Installed at D:\lamw\android-sdk-windows

-setup:
     [echo] Project Name: LamwGUIProject2
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:

[getbuildtools] Using latest Build Tools: 25.0.2
     [echo] Resolving Build Target for LamwGUIProject2...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: D:\App\LamwGUIProject2\bin\rsObj
    [mkdir] Created dir: D:\App\LamwGUIProject2\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for LamwGUIProject2...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------


     [echo] Handling Resources...
     [aapt] Found Deleted Target File
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 5 source files to D:\App\LamwGUIProject2\bin\classes

    [javac] D:\App\LamwGUIProject2\src\org\lamw\lamwguiproject2\android-17\App.java:75: error: method jAppOnCreate in class Controls cannot be applied to given types;
    [javac]       controls.jAppOnCreate(this, controls.appLayout);
    [javac]               ^
    [javac]   required: Context,RelativeLayout,Intent
    [javac]   found: App,RelativeLayout
    [javac]   reason: actual and formal argument lists differ in length
    [javac] D:\App\LamwGUIProject2\src\org\lamw\lamwguiproject2\android-17\App.java:80: error: method jAppOnNewIntent in class Controls cannot be applied to given types;
    [javac]     protected void onNewIntent(Intent intent) {super.onNewIntent(intent); controls.jAppOnNewIntent();}
    [javac]                                                                                   ^
    [javac]   required: Intent
    [javac]   found: no arguments
    [javac]   reason: actual and formal argument lists differ in length

    [javac] 2 errors

Any help please?


Win8.1: laz4android1.5-50093-FPC3.1.1
LAMW: 0.7.14
Title: Re: Android Module Wizard
Post by: jmpessoa on March 29, 2017, 10:12:04 pm

Fixed!

Please, update from github

ref.

https://github.com/jmpessoa/lazandroidmodulewizard

Thank you!
Title: Re: Android Module Wizard
Post by: liyuangarcia on March 29, 2017, 10:49:30 pm
Great Job. Working fine!

Congratulations!
Title: Re: Android Module Wizard
Post by: jmpessoa on March 30, 2017, 06:43:10 am
Hi All!

There is a new LAMW revision!

ref.    https://github.com/jmpessoa/lazandroidmodulewizard


Version 0.7.15 - 29 - March - 2017

   NEW! jTextToSpeech  component

   NEW! demo AppTextToSpeechDemo1

   UPDATED! demo AppCustomFontDemo1 --- Added Font Awesome Icons example


Thanks to All
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 02, 2017, 03:31:51 pm
can I implement admob banner to app ?
and if, how to do ?
thanks much :) :)
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 04, 2017, 05:14:37 pm
I have problem with new version
I used code
if(AndroidModule2 = nil) then
  begin
      gApp.CreateForm(TAndroidModule2, AndroidModule2);
      AndroidModule2.Init(gApp);
  end
  else
  begin
    AndroidModule2.Show;
    androidmodule1.Finish;
  end;     

but android module 1 doesnt close, it still be there with android module 2
Title: Re: Android Module Wizard
Post by: jmpessoa on April 05, 2017, 12:25:05 am
Hi m4u!

We have only a screen, so we need  set the form2 background
to some  color .... [not default/transparent]

NOTE: androidmodule1.Finish not is recommendad.

About admob banner:

Good suggestion!

I will try some implementation!

Thank you!


Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on April 05, 2017, 04:26:48 am
Hi m4u!

We have only a screen, so we need  set the form2 background
to some  color .... [not default/transparent]

NOTE: androidmodule1.Finish not is recommendad.

About admob banner:

Good suggestion!

I will try some implementation!

Thank you!

About form, in previous versions we neednt set background color to hide them and i still use this until this update. Anyway thanks much :) :)
Hope admob will be intergrated soon.
Title: Re: Android Module Wizard
Post by: majid.ebru on April 15, 2017, 03:28:35 pm
Hi
Mr.jmpessoa updated LAMW.
.
he added Alphta Transparent.
.
i think he forgot (maybe)?!?!
.
he Improved  jPanel and jTextView => [SetBackgroundAlpha]
.
.
thank you very much :-* :-* :-* :-* :-*
Title: Re: Android Module Wizard
Post by: jmpessoa on April 30, 2017, 07:16:32 am
Hi All!

There is a new LAMW revision!

Version 0.7.16 - 29 - April - 2017

   NEW! jSMSWidgetProvider component

   NEW! demo AppSMSWidgetProviderDemo1

      HINT 1: How to install widget:

         a)Run/Install the App
         b) Use BackButton to leave the App
         c) long press the home screen and select "widgets"
         d) loook for "AppSMSWidgetProviderDemo1 4x1"
         f) long press "AppSMSWidgetProviderDemo1 4x1" to install
         g) keep waiting for a "sms"
         h) has sms arrived? click the widget to re-open and hanlde the message from your App!

      HINT 2: Configure your project:

      res/layout
         smswigetlayout.xml    <<-- change [only content, NOT the file name] to configure
      res/drawable-xxxx
         smswidgetbackgroundimage.jpg  <<-- change [only content, NOT the file name]  to configure
      res/xml
         smswidgetinfo.xml   <<-- change [only content,  NOT the file name]  to configure
         

   IMPROVED! jSqliteDataAccess ["java" template all rewrited by Renabor!]
         NEW! support to pack [and automatic handle] database in "assets" folder
         NEW! support to database version-control

   NEW! demo AppSQliteDemo3  <<--- demo for "assets" support... [thanks to Renabor!]
         NOTE: how to store your pre-build database:
            ..../assets   <<--- put your database file here [default]
               ....assets/databases  <<--- OR put your file here [default, too!]
               ....assets/myCustomFolderName  <<-- ????? OR put your file here [not default!]

               if you prefere "myCustomFolderName" as folder name then call:
                  jSqliteDataAccess1.SetAssetsSearchFolder("myCustomFolderName");
                  in "OnJNIPrompt" event.                  

   UPDATED! demo AppSQliteDemo1 
   UPDATED! demo AppSQliteDemo2   


Thanks to All!

Special thanks to Renabor!
Title: Re: Android Module Wizard
Post by: georgebou on April 30, 2017, 03:19:44 pm
Thanks for the example man.

I will test it as soon as i get back to my main PC :)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2017, 06:07:25 am

Hi All!

There is a new LAMW revision!

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

version 0.7 - rev. 17 - 14 May - 2017

   NEW! jSpeechToText component

   NEW! demo AppSpeechToTextDemo1

   Improved!
      jListView
         property "TextAlign" now works for "only text" items
      
      jSpinner: Added methods to support "hidden" tag by item         
         SetItem(_index: integer; _item: string; _strTag: string)
         Add(_item: string; _strTag: string);
         GetItemTagString(_index: integer): string
         SetItemTagString(_index: integer; _strTag: string);

   Fixed!
      jTextView/jEditText
         property "Alignment" now works for "LParamWidth = lpMatchParent"

Thanks to All!
Title: Re: Android Module Wizard
Post by: Lucian Todor on May 16, 2017, 10:50:51 am
I've just updated the repo and rebuild the lazarus. After that, I observed that the jListView items overlaps with their image. I tried then the ListView demo and I have the same effect.

Note: I use API 17.

Further, I'm wondering, is it possible to set subtext description for each jListView item, something similar like subtitle from the action bar?
I would like to express my appreciation for this great tool. :-)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 17, 2017, 03:39:51 am
Hello Luciantodor!

I tried some fix. Please update from github...

[Note: use the property TextAlign for  a not  overlaps layout]

Yes, it is!  just code a item as [ex]    "LAMW|Lazarus|Android" 
and use the properties TextSizeDecoreted, TextDecoreted and FontSize ... to get
the subtitles

Thank you!
Title: Re: Android Module Wizard
Post by: Lucian Todor on May 17, 2017, 11:10:35 am
The text size decoration and it's delimiter really works. Thank you for your hint and fast response.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 20, 2017, 08:35:36 am

Hi All!

There is a new LAMW revision!

ref.  https://github.com/jmpessoa/lazandroidmodulewizard


version 0.7 - rev. 18 - 20 May - 2017

   NEW! jModalDialog component   //<--- a suggestion by Anton (aka A.S.)!
         .ShowMessage
         .InputForActivityResult
         .QuestionForActivityResult

   NEW! demo AppModalDialogDemo1

   Improved!
      jListView
         New event "OnScrollStateChanged"  //<--- a suggestion by Anton!

   Updated
      jListViewDemo


Thanks to All!
Title: Re: Android Module Wizard
Post by: jmpessoa on June 17, 2017, 06:27:57 am

Hi All!

There is a new LAMW revision!

ref.   https://github.com/jmpessoa/lazandroidmodulewizard

version 0.7 - rev. 19 - 16 June - 2017

   NEW! jComboEditText component  ["ComboBox" like]   

   NEW! demo AppComboEditTextDemo1

   Improved!
      jEditText
      jAutoTextView
      jListView
      jSpinner

   NEW!
      IDE Tools: Added new option "ADB Logcat"

Thanks to All!
Title: Re: Android Module Wizard
Post by: majid.ebru on June 17, 2017, 02:23:56 pm
thank you very much
Title: Re: Android Module Wizard
Post by: lucabertoncini on July 16, 2017, 11:17:57 am
Hello JMPessoa,
first of all lamw is a wonderful work!
I’m a freepascal developer, as some of us, I need to create an Android App that interacts with my freepascal softwares. I’ve written the App using Android Studio, but I’ve some problems to understand at all the Android’s way of thinking. I’m evaluating lamw to rewrite the App with this framework. There are 2 aspects I need to investigate.

First
The App executes some HTTP Post to a https server. I use HttpsURLConnection object to post the data. The data I need to send is a JSON-string (not a Name / Value). To do this with jHttpClient, I need to access the equivalent of the output-stream as I do in Java. Is there any way to achieve this?

Second
The App is connected by a TCP socket to a server and receives or sends data in a binary way (I don’t use strings). Is it possible with jTCPSocketClient?

I don’t have enough knowledge to modify or create jObjects. If you have tutorials or documents that can explain how to create bridge objects, I will be interested to study these documents and to try to solve the problems by myself. Every help will be appreciated!

Thank you very much.
Title: Re: Android Module Wizard
Post by: jmpessoa on July 16, 2017, 09:36:28 pm

Hello, lucabertoncini!

Yes, jHttpClient and jTCPSocketClient can meet your requirements.. please go to
some app "demos" stuff ....

But, you can try, too, many pure freepascal FLC stuff [example:  fphttpclient ...]

If you need improve [or create] a component I can help you....
Title: Re: Android Module Wizard
Post by: lucabertoncini on July 17, 2017, 01:40:17 pm
Hi JMPessoa,
thanks for your time.
I took a look at the demos to try to understand how to use this interesting code.
If I’m right, to be able to post a JSON string with jHTTPClient I should write a procedure similar to jHTTPClient_AddValueForPost2 but with only a single parameter.


Something like

procedure jHTTPClient_AddStringForPost(env: PJNIEnv; _jHTTPClient: JObject; _AString: string);
  var
  jParams: array[0..0] of jValue;
  jMethod: jMethodID = nil;
  jCls: jClass = nil;
begin
  jParams[0].l := env^.NewStringUTF(env, PChar(_AString));
  jCls := env^.GetObjectClass(env, _jHTTPClient);
  jMethod := env^.GetMethodID(env, jCls, 'AddStringForPost', '(Ljava/lang/String;)V');
  env^.CallVoidMethodA(env, _jHTTPClient, jMethod, @jParams);
  env^.DeleteLocalRef(env, jParams[0].l);
  env^.DeleteLocalRef(env, jCls);
end;

What about an https connection? In Android I need to use a different object  HttpsURLConnection.
In this case I need to change the function jHttpClient_Post with this:
jMethod := env^.GetMethodID(env, jCls, 'Post', '(Ljava/net/HttpsURLConnection;)Ljava/lang/String;');

These are the two test I'll do in the next days. Do you think it is the right way?
Title: Re: Android Module Wizard
Post by: lucabertoncini on July 17, 2017, 05:00:27 pm
I've found this tutorial.

http://www.pacifier.com/~mmead/jni/delphi/JEDI/DOCS/delphi-jni-1.html

Everything I wrote in the previous post was wrong!

I'll try the way of using fphttpclient and fpsock library.

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on July 17, 2017, 06:16:08 pm

Quote
http://www.pacifier.com/~mmead/jni/delphi/JEDI/DOCS/delphi-jni-1.html

Yes, a great "core" tutorial....

But LAMW code architecture is much easier!

First we write a java class to wrapper some android API..
Example:  jHttpClient is a wrapper for android HttpsURLConnection...
See the demos "AppHttpClientDemo1" and AppHttpClientDemo2 .....AppHttpClientCookiesDemo1, etc...
You can see the java stuff in folder "YourProject/scr/........."

Note: To use fpc FCL core, you often need to copy the source code to you project
"jni"  folder ....
Example: To use  "fphttpclient" copy "fphttpclient.pp",  "httpdefs.pp" and "httpprotocol.pp" to you project "jni" folder

But, I think you can try first the LAMW jComponents!
Title: Re: Android Module Wizard
Post by: lucabertoncini on July 17, 2017, 06:23:32 pm
Ok, in the next days I'll go deeper. Thanks!
Title: Re: Android Module Wizard
Post by: c4p on August 23, 2017, 11:09:43 am
Just a note of thanks to jmpessoa and others contributing to the fantastic LAMW project.  8-)

 :D
Title: Re: Android Module Wizard
Post by: januszchmiel on September 01, 2017, 08:48:32 pm
Dear specialists,
I Am new user on this forum. My name is Janusz Chmiel. I Am visually impaired user with no sight at all. I would like to express my deepest possible appreciation to all of you, who have developed so amazing component for Lazarus. I AM able to use all of yours provided demo examples while using it with Talkback screen reader. I Am very very glad, that you have enabled visually impaired to use compiled Android apps created by using yours component. I have only one programmers plea to you. When programmer add background special command, so app can run at background. Does running program allocate so much RAM, that Android memory management can start to automatically kill some processes? I AM afraid, that if I will listen live Internet radio and app will run at The background, that app will automatically allocate so much RAM, that my favourite Talkback screen reader would be automatically terminated by Android memory management algorithms. Or I do not have to have fair because of it. Because resulting app is optimized also because of RAM allocations? Sure, I know, that it depend also on programming techniques which will be used by Pascal programmer. Really, very well done. I have never thought, that i would be able to find so perfect freeware solution.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 03, 2017, 09:48:15 pm
Quote
Does running program allocate so much RAM, that Android memory management can start to automatically kill some processes?

Yes...  and  Android algorithm has often changed....
Title: Re: Android Module Wizard
Post by: januszchmiel on September 07, 2017, 06:21:17 pm
Dear specialists,
Would somebody of us write me commands, which I had to add to have wakelock set to The walue, so background tasks will be working even when I turn The phone screen off? If I will place such commands to The unit1.pas and external .so library will be called from here. Will be wakelock applied also for internal machine code of native C .so library which will be called? I Am afraid, that Android would suspend threads from native external library. Or i do not have to think so? So please, which lines and which commands should be part of The .pas source code? Thank you very much.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 09, 2017, 11:21:56 pm

Hi All,

The "Skywave Radio Schedules" app  by  @c4p
[powered by FPC+Lazarus+LAMW !]

is  now on Google Play!

https://play.google.com/store/apps/details?id=swbcdx.cap.shortwavelist

thanks and congratulations to  @c4p!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 15, 2017, 01:20:44 am
Hi All,

There is a LAMW update! [improved support to material theme]

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7 - rev. 21 - 14 - October - 2017

   NEW! jToolbar component  [to use only with  "minSkd=21" and "targetSdk >= 21"] <<--- a request from @Tomash

   NEW! demo AppToolbarDemo1 [generic use of jToolbar as a specialized panel/visualContainer]

   NEW! demo AppToolbarDemo2 [use Toolbar as "Actionbar". NOTE: configured theme/style as "android:Theme.Material.Light.NoActionBar"
               in "...res\values-21\style.xml"]

      HINT 1: Configure your project colors:

         Go to project folder "....res/values/colors.xml" <----- change [only content, NOT the file name] to configure colors
            
            Reference is here:
            http://www.vogella.com/tutorials/AndroidStylesThemes/article.html#styling-the-color-palette

      HINT 2: if you change default ["colbrRoyalBlue"] jToolbar background color in design time,
         You should change "primary_dark" in "color.xml" according "material" guideline
         [a little more darker than the toolbar color]
         Reference is here: https://www.materialpalette.com/   


Thanks to All!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 22, 2017, 08:38:26 pm

Hi All,

There is a LAMW update!

ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7 - rev. 22 - 21 - October - 2017

   NEW! jExpandableListView component

   NEW! demo AppExpandableListViewDemo1

   IMPROVED! jTextToSpeech
         Added method "SpeakOnline"   [Thanks to  @Freris]


Thanks to All!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 05, 2017, 08:24:35 am
hi jmpessoa
can i implement admob to my app ?  :) :)
Title: Re: Android Module Wizard
Post by: jmpessoa on November 07, 2017, 05:42:02 am
Hi m4u!

I will try implement admob support as soon as possible!

[At the  moment, I am working to add gradle support ....]
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 12, 2017, 04:47:08 am
I use laz4android 1.7
newest lamw version
If i create new project with 2 forms, form1 has 1 jbutton, when I create second form, IDE will crash
I dont know why

If i dont use jbutton and use jimgbutton instead, everything is ok

I tried some cases
I have 2 forms, if form1 has jbutton,jedittext,jlabel,jradiobutton,jcheck , the form2 cant have those because IDE will crash
I concluded I just can put those components on 1 form, other forms have them will cause IDE crash
Title: Re: Android Module Wizard
Post by: DonAlfredo on November 12, 2017, 07:09:02 am
Look at this commit for LAMW:
https://github.com/jmpessoa/lazandroidmodulewizard/commit/53f4605c6f59176eb6176bec78158c2b6ebc2a6d
You could try to apply the changes if this commit .

Or you could use fpcupdeluxe to install all brand new and updated.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 12, 2017, 08:53:51 am
Look at this commit for LAMW:
https://github.com/jmpessoa/lazandroidmodulewizard/commit/53f4605c6f59176eb6176bec78158c2b6ebc2a6d
You could try to apply the changes if this commit .

Or you could use fpcupdeluxe to install all brand new and updated.

I tried above commit, but seem jmpessoa deleted functions including
"function CmpAndroidThemes(p1, p2: Pointer): Integer;"
and " function FindThemeByName(p1, p2: Pointer): Integer;"
but i still copied  all as commit said, but cant solve the problem
Title: Re: Android Module Wizard
Post by: jmpessoa on November 13, 2017, 04:34:14 am

Hi m4u!

Please, update your LAMW stuff ... there is a new fix!
Title: Re: Android Module Wizard
Post by: kwer on November 16, 2017, 04:36:51 am
====  How to new a Lamw component? ====
clientsocket := jTCPSocketClient.Create(gApp); // But it doesn't work!!!
clientsocket.Init(gApp);  // Crashed!!!
Title: Re: Android Module Wizard
Post by: jmpessoa on November 16, 2017, 05:08:09 am


Are you off the form?
if not try:

clientsocket := jTCPSocketClient.Create(Self); // <=== changed here...
clientsocket.Init(gApp); 
Title: Re: Android Module Wizard
Post by: llg523 on November 26, 2017, 12:24:33 pm
Hi jmpessoa,

Thank you very much for your great work!

I would like to try my app by LAMW. I found there is just TCP Client demo, however in my app the phone need to be as a sever, is there any solution? Thanks a lot!
Title: Re: Android Module Wizard
Post by: jmpessoa on November 26, 2017, 06:36:56 pm

From google:

http://programminglife.io/android-http-server-with-nanohttpd/

I will try  [TODO] some "nanohttpd" wrapper for LAMW!

Thank you!
Title: Re: Android Module Wizard
Post by: llg523 on November 28, 2017, 04:11:18 am
Hi jmpessoa,

Thank you very much for quick response!
If I just want a TCP server while don't need to support http, is there a simple solution?
Title: Re: Android Module Wizard
Post by: kwer on November 28, 2017, 04:27:01 am
Hi jmpessoa,  something made me wonder.

(uses fpjson)
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
   jData : TJSONData;
   jObject : TJSONObject;
   jArray : TJSONArray;
   s : string;
begin
   // create from string
   jData := GetJSON('{"Fld1" : "Hello", "Fld2" : 42, "Colors" : ["Red", "Green", "Blue"]}');  // Crashed!!!

--
Title: Re: Android Module Wizard
Post by: jmpessoa on November 28, 2017, 04:40:45 am

Hello kwer!

Sorry...we dont have native java json support, yet....

You can try  pure  FPC JSON  .... at  fpc\3.1.1\source\packages\fcl-json
[maybe, you will need copy the source to your project folder...]


Title: Re: Android Module Wizard
Post by: A.S. on November 28, 2017, 07:40:47 pm
Hi jmpessoa,  something made me wonder.

(uses fpjson)
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
   jData : TJSONData;
   jObject : TJSONObject;
   jArray : TJSONArray;
   s : string;
begin
   // create from string
   jData := GetJSON('{"Fld1" : "Hello", "Fld2" : 42, "Colors" : ["Red", "Green", "Blue"]}');  // Crashed!!!

--

Include "jsonparser" unit to uses clause.
Title: Re: Android Module Wizard
Post by: trevor on January 23, 2018, 10:15:02 am
How to add 2/3/4/5 lines to all items of Android Native ListView?
Title: Re: Android Module Wizard
Post by: jmpessoa on January 23, 2018, 04:03:31 pm

Hello, Trevor!

Can you put here some "draft" picture?
Title: Re: Android Module Wizard
Post by: trevor on January 24, 2018, 06:24:45 am

Hello, Trevor!

Can you put here some "draft" picture?
Hello!
Thank you for your AMW!

I want something just like this :)
Title: Re: Android Module Wizard
Post by: jmpessoa on January 24, 2018, 04:20:35 pm
OK.

Try:

jListView1.Add(Text1|Text2|Text3);

and you can configure  this properties:

TextAlign
TextDecorated
TextSizeDecorated

Title: Re: Android Module Wizard
Post by: trevor on January 25, 2018, 11:32:35 am
OK.

Try:

jListView1.Add(Text1|Text2|Text3);

and you can configure  this properties:

TextAlign
TextDecorated
TextSizeDecorated
Thanks a lot! :thumbsup:
Title: Potential Flaw in Android Module Wizard
Post by: Martin Lowry on January 31, 2018, 01:08:30 pm
Hi All,

I've been using LAMW now for nearly a month and am very impressed with it. It's obviously taken a huge amount of work to get it to where it is now. Congratulations and thanks.

However I do have a problem  (isn't there always one  :)). I'm writing a database App using jSQLDataaccess and jSQLCursor with jGridview to display my data. Unfortunately there isn't a jDBGridView (I know it would be a big task but much appreciated) so I'm stringing these together on the native code side like so:

for R := 0 to sqlCursor.RowCount-1 do
begin
  for C := 0 to sqlCursor.ColCount-1 do
    Gridview.Cells(C, R) := sqlCursor.GetValueAsString(c);
  sqlCursor.MoveToNext;
end;

and here come the issue, I can't display all my records in the Gridview without running out of local reference space in the JNI.  I trace this to the JNI function 'jSqliteCursor_GetValueAsString' in 'And_jni_Bridge.pas' which uses GetStringUTFChars to obtain the field value. It returns to my function without ever calling ReleaseStringUTFChars so the references accumulate in the JNI and eventually cause the App to crash. The JNI spec recommends always to call ReleaseStringUTFChars, irrespective of the value of the isCopy parameter to GetStringUTFChars so that its local reference stack can be cleaned by the GC process.  I've tried several solutions to make a copy of the string value and then call ReleaseStringUTFChars but they all fail with the same error.  Does anybody have a solution?

This mechanism is used in several places in LAMW so could potentially cause problems in other situations too.

Your responses awaited with eagerness :)

Cheers

2-2-18  Edited out the silly mistake :) The problem remains.
Title: Re: Android Module Wizard
Post by: jmpessoa on February 02, 2018, 12:41:27 am
What about:

Code: Pascal  [Select][+][-]
  1. for R := 0 to sqlCursor.RowCount -1  do   // <<-----try change here
  2. begin
  3.     for C := 0 to sqlCursor.ColCount - 1 do   // <<-----try change here
  4.     begin
  5.     .....
  6.     end;
  7. end
  8.  
Title: Re: Android Module Wizard
Post by: Martin Lowry on February 02, 2018, 12:06:13 pm
Hi jmpessoa,

Whoops, that was a silly mistake in my pseudo-code (now edited). What you wrote was what I was actually doing in the App, so the problem remains.

Cheers
Title: Re: Android Module Wizard
Post by: jmpessoa on February 02, 2018, 04:07:55 pm

Ok. Write here you rowCount and colCount ....
[maybe a gridview capacity ???]
Title: Re: Android Module Wizard
Post by: Martin Lowry on February 02, 2018, 05:32:24 pm
Hi jmpessoa,

Quite a small table really for a DB,  120 rows by 18 columns, all fields as strings.  Would that be too big for a gridview?

What really got me posting was the logcat output: see attached.

Cheers


Title: Re: Android Module Wizard
Post by: Horas on March 10, 2018, 10:29:10 am
Dear jmpessoa,
  I'm using LAMW for quit some time now, and I would like to thank you and please improve it more and keep it upto datey.
I would like to upload an image file to my http server using httpclient post, Can you help me.
jHttpClient looks like doesn't support file upload, please can you provide me with an example code to upload file or image from the android mobile to http server
Many thanks,
Horas
Title: Re: Android Module Wizard
Post by: jmpessoa on March 11, 2018, 03:18:36 am
Hello, Horas!

I will try improve jHttpClient!

Thank you!

PS.

As a side note: you can try pure fpc stuff...
put this units [from: "\lazarus\fpc\3.1.1\source\packages\fcl-web\src\base"]
fphttpclient.pp
httpdefs.pp
httpprotocol.pp

 in your project  "....\jni"  folder:

The "GET" sample is here:

Code: Pascal  [Select][+][-]
  1. unit unit1;
  2.  
  3. {$mode delphi}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, fphttpclient, httpdefs,
  9.   httpprotocol;
  10.  
  11. type
  12.  
  13.   { TAndroidModule1 }
  14.  
  15.   TAndroidModule1 = class(jForm)
  16.     jButton1: jButton;
  17.     procedure jButton1Click(Sender: TObject);
  18.   private
  19.     {private declarations}
  20.   public
  21.     {public declarations}
  22.   end;
  23.  
  24. var
  25.   AndroidModule1: TAndroidModule1;
  26.  
  27. implementation
  28.  
  29. {$R *.lfm}
  30.  
  31.  
  32. { TAndroidModule1 }
  33.  
  34. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  35. var
  36.   resp: string;
  37. begin
  38.      With TFPHTTPClient.Create(Nil) do
  39.       try
  40.          resp:= Get('http://....');
  41.       finally
  42.         Free;
  43.       end;
  44.       ShowMessage(resp);
  45. end;
  46.  
Title: LAMW: onNewIntent
Post by: Martin Lowry on March 23, 2018, 04:43:24 pm
Hi,

I was hoping to use Activity.onNewIntent to communicate new data to a single_instance task but see that the event is not surfaced in jForm even though all the necessary code is present in App.java, Controls.java and AndroidWidget.pas.  Will it work if I just un-comment the appropriate lines?

Cheers
Title: Re: Android Module Wizard
Post by: Sergei on March 24, 2018, 02:52:03 pm
Hello,

writing for the first time here, so thanks a lot for the LAMW tools, the Lazarus + LAMW approach to Android development seems rocket-fast compared to the alternatives. Also I like the LAMW widget model, it seems to me more straightforward than the LCL applied to mobile devices.

I need your LAMW experts' help though. As I tried creation of the wrappers around an Android widget, I used the Smart LAMW Designer tool (my config is Laz4android 1.8/ FPC 3.0.4 on Windows 10 x64, Android platform 19, Android SDK from tools_r25.2.5-windows):
   
My question is about these fragments in the generated Pascal code:
Code: Pascal  [Select][+][-]
  1. unit lass;
  2. class = class(jVisualControl)
  3. constructor class.Create(AOwner: TComponent);
  4. procedure class_SetBackgroundDrawable(env: PJNIEnv; _class: JObject; _imageIdentifier: string);
   
Is that possible to somehow configure the tool to generate something like this instead:
Code: Pascal  [Select][+][-]
  1. unit togglebutton;
  2. jToggleButton = class(jVisualControl)
  3. constructor jToggleButton.Create(AOwner: TComponent);
  4. procedure jToggleButton_SetBackgroundDrawable(env: PJNIEnv; _class: JObject; _imageIdentifier: string);
   
I understand, that jToggleButton is already there, but I saw the same behavior for any Java class name.

Thank you for your help,
Sergei
Title: Re: Android Module Wizard
Post by: jmpessoa on March 24, 2018, 05:05:07 pm
Hi, Sergei!

Quote
class = class(jVisualControl)

Here we got a bug!!!

Please change "public class jToggleButton"  to  "class jToggleButton" before
right-clicked > Write  [Draft] Pascal jVisualControl Interface...
Title: Re: Android Module Wizard
Post by: Sergei on March 24, 2018, 05:48:57 pm
Thank you so much, the workaround works here!
Title: Re: Android Module Wizard
Post by: Sergei on March 26, 2018, 12:18:37 pm
Hi Jose, experts,

is that possible to create a LAMW wrapper for a 3-rd party widget, indirectly subclassing Android SDK widgets?

I am trying to connect the MaskEditText widget (https://github.com/santalu/mask-edittext (https://github.com/santalu/mask-edittext)). The widget is inheriting from android.support.v7.widget.AppCompatEditText and sits in its com.santalu.maskedittext package. I tried to create a directory structure for that package in several places of the source tree, but to no avail. Most likely modifications to the Gradle build are necessary too.

Also, if a widget had dependencies to jars/Gradle artifacts in outside repos, how can I configure tfpandroidbridge_pack.lpk or my project?

Any pointers are highly appreciated.
Sergei
Title: Re: Android Module Wizard
Post by: jmpessoa on March 27, 2018, 01:24:35 am
Hi Sergei!

Incoming "LAMW 0.8"  will support  "google support libraries" (AppCompat,  design, Cardview,  ReciclerView, etc..) and Gradle build system ...

A preview is here:     https://od.lk/f/Ml8xNTU4Mjc1NDVf     [updated!!!]

It would be interesting someone could do some testing before a major update of the git repository ....

   NEW! "AppCompat" material theme support!
   NEW! "Android Bridges Support" component palete to support "AppCompat" material theme!
      NEW! jsDrawerLayout component
      NEW! jsNavigationView component
      NEW! jsCoordinatorLayout component
      NEW! jsAppBarLayout component
      NEW! jsCollapsingToolbarLayout component
      NEW! jsToolbar component
      NEW! jsTabLayout component
      NEW! jsNestedScrollView component
      NEW! jsRecyclerView component
      NEW! jsViewPager component
      NEW! jsCardView component
      NEW! jsFloatingButton component
      NEW! jsBottomNavigationView component
      NEW! jsTextInput component

   NEW! demo AppCompatFloatingButtonDemo1
   NEW! demo AppCompatViewPagerDemo1
   NEW! demo AppCompatNavigationDrawerDemo1
   NEW! demo AppCompatCollapsingToolbarDemo1
   NEW! demo AppCompatTabLayoutDemo1
   NEW! demo AppCompatTabLayoutDemo2

   NEW! jDBListView component by Martin Lowry [Thanks!]
   NEW! demo AppDBGridViewDemo1  by Martin Lowry [Thanks!]

       Edited: demos preview:  https://od.lk/f/Ml8xNTU3ODQyMDlf
   REQUIREMENTS:

      [LAMW 0.8] "AppCompat" [material] theme need:
      1. Java JDK 1.8
      2. Gradle 4.1
      3. Android SDK "plataforms" 25 + "build-tools" 25.0.3 [or]
      3. Android SDK "plataforms" 26 + "build-tools" 26.0.3 [or]
      3. Android SDK "plataforms" 27 + "build-tools" 27.0.3
      4. Android SDK/Extra  "Support Repository"
      5. Android SDK/Extra  "Support Library"


Thanks!
Title: Re: Android Module Wizard
Post by: Sergei on March 28, 2018, 04:18:30 pm
Many thanks for sharing the 0.8 preview, seems like a huge amount of work has been done.

Installation went smoothly, but I was not able to use the packages as my android-26 config was not recognized in the new project form.

I would love to try tackling the code, can you give me some light on how to debug the 3 *.lpk packages in the most efficient way? What strategy are you using? Is there any integration test somewhere to initialize and run the forms?

Title: Re: Android Module Wizard
Post by: jmpessoa on March 28, 2018, 11:15:09 pm
Quote
but I was not able to use the packages as my android-26 config was not recognized in the new project form.

You can look in "...sdk\build-tools" if you lost the "26.x.x"  folder...

You can try  "uformworkspace.pas"  code [LAMW folder "android_wizard"] ... look for
method "GetMaxSdkPlatform" in line:

Code: Pascal  [Select][+][-]
  1. if HasBuildTools(intAux, outBuildTool) then  Result:= intAux;
  2.  

Edited:

LAMW 0.8 preview:  https://od.lk/f/Ml8xNTU4Mjc1NDVf [updated!!!]

demos preview:  https://od.lk/f/Ml8xNTU3ODQyMDlf

Title: Re: Android Module Wizard
Post by: ocloma on April 02, 2018, 07:07:42 pm
Very nice work! Thanks!
Title: Re: Android Module Wizard
Post by: jmpessoa on April 02, 2018, 10:09:40 pm

Hi All!

There is new major LAMW 0.8 version!

ref.   https://github.com/jmpessoa/lazandroidmodulewizard

   NEW! "AppCompat" material theme support!
   NEW! "Android Bridges Support" component palete to support "AppCompat" material theme!
      NEW! jsDrawerLayout component
      NEW! jsNavigationView component
      NEW! jsCoordinatorLayout component
      NEW! jsAppBarLayout component
      NEW! jsCollapsingToolbarLayout component
      NEW! jsToolbar component
      NEW! jsTabLayout component
      NEW! jsNestedScrollView component
      NEW! jsRecyclerView component
      NEW! jsViewPager component
      NEW! jsCardView component
      NEW! jsFloatingButton component
      NEW! jsBottomNavigationView component
      NEW! jsTextInput component

   NEW! demo AppCompatFloatingButtonDemo1
   NEW! demo AppCompatViewPagerDemo1
   NEW! demo AppCompatNavigationDrawerDemo1
   NEW! demo AppCompatCollapsingToolbarDemo1
   NEW! demo AppCompatTabLayoutDemo1
   NEW! demo AppCompatTabLayoutDemo2

   NEW! jDBListView component by Martin Lowry [Thanks!]
   NEW! demo AppDBGridViewDemo1  by Martin Lowry [Thanks!]

   REQUIREMENTS:

      [LAMW 0.8] "AppCompat" [material] theme need:

      1. Java JDK 1.8

      2. Gradle 4.1 + Internet Connection!
      https://gradle.org/next-steps/?version=4.1&format=bin
      Simply extract the zip file to a convenient location...

      3. Android SDK "plataforms" 25 + "build-tools" 25.0.3 [or]
      3. Android SDK "plataforms" 26 + "build-tools" 26.0.3 [or]
      3. Android SDK "plataforms" 27 + "build-tools" 27.0.3
      4. Android SDK/Extra  "Support Repository"
      5. Android SDK/Extra  "Support Library"
      
      Hint. [Gradle] If your connection has a proxy, edit the "gradle.properties" file content. Example:
 
         systemProp.http.proxyHost=10.0.16.1
         systemProp.http.proxyPort=3128
         systemProp.https.proxyHost=10.0.16.1
         systemProp.https.proxyPort=3128

Thanks to All!
Title: Re: Android Module Wizard
Post by: arirod on April 04, 2018, 07:36:40 am
srs. sobre a release 0.8...instalacao WayneSherman
crio um projeto novo GUI, com apenas um botao sem eventos
quando executo "Build Android APK and Run"...retorna erros que nao consegui resolver...peço orientacoes!
//------------------
Messages, Hints: 2
Verbose: Selected chip architecture: armeabi-v7a
Verbose: Taking libraries from folder: /home/aeondc/lamw-projetos/proj2/libs/armeabi-v7a
Verbose: Found library: libcontrols.so
Note: Duplicate unit "controls" in "controls", orphaned ppu "/home/aeondc/lamw-projetos/proj2/obj/controls/controls.o"
Note: Duplicate unit "controls" in "LCLBase 1.9", ppu="/home/aeondc/fpcupdeluxe/lazarus/lcl/units/arm-android/controls.ppu", source="/home/aeondc/fpcupdeluxe/lazarus/lcl/controls.pp"
Compile Project, OS: android, CPU: arm, Target: /home/aeondc/lamw-projetos/proj2/libs/armeabi-v7a/libcontrols.so: Success
Building APK (Gradle)... : Exit code 256, Errors: 2
Panic: xfce4-terminal: Opção desconhecida "clean"
Panic: tool stopped with exit code 256. Use context menu to get more information.
Exception, Errors: 1
Fatal: [Exception] Failed: Cannot build APK!
//------------------
obrigado!
Title: Re: Android Module Wizard
Post by: WayneSherman on April 05, 2018, 01:26:11 am
Quote
Building APK (Gradle)... : Exit code 256, Errors: 2
Panic: xfce4-terminal: Opção desconhecida "clean"
Panic: tool stopped with exit code 256. Use context menu to get more information.
Exception, Errors: 1
Fatal: [Exception] Failed: Cannot build APK!

Some things to check and try:
1) Make sure you have gradle installed according to the instructions (see section 3.4. Environment variables (https://docs.gradle.org/4.1/userguide/installation.html#sec:installation_environment_variables))
2) Edit gradle_local_build.sh to correct errors. (possibly all you need is one line:  gradle clean build --info)
3) Give gradle_local_build.sh execute permission
4) Try running gradle_local_build.sh from a command line.


Title: Re: Android Module Wizard
Post by: arirod on April 05, 2018, 07:57:41 pm
https://youtu.be/uDzZkwf3CL4
Title: Re: Android Module Wizard
Post by: jmpessoa on April 05, 2018, 11:21:55 pm

Muito Bom, Ari!

Obrigado!
Title: Re: Android Module Wizard
Post by: WayneSherman on April 06, 2018, 01:08:17 am
I didn't understand everything, but good job on the tutorial.
Title: Re: Android Module Wizard
Post by: mr-highball on April 16, 2018, 07:47:33 pm
First, this is a wonderful project, and I appreciate all the work you have put into it.

I'd like to see if there has been any thoughts/progress on background services?
Last year you mentioned there was no support for services, but I figured things can change in a year :)
https://forum.lazarus.freepascal.org/index.php/topic,36201.msg240997.html#msg240997

Embarcadero's approach to android services
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Android_Service
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Creating_Android_Services

I recently just stumbled upon LAMW so pardon if this has been asked/answered before.
Thanks for your time,
Title: Re: Android Module Wizard
Post by: jmpessoa on April 17, 2018, 01:53:57 am
Hello, Mr-Highball!

Sorry...  but  LAMW  do not support  custom user defined service, yet ...

[The LAMW 0.8    development focus  was "material design" and "support libraries" ....]

Now,  I will can try some approach to support "custom user defined service" ....

Until there, if you have some need for a specific service, I can try help you!

Thank you!
Title: Re: Android Module Wizard
Post by: mr-highball on April 17, 2018, 06:03:34 pm
Thank you for the reply! I thought as such, but I figured I would ask. I don't have a specific need now, but I like to tinker, so something may come up in the future.
Title: Re: Android Module Wizard
Post by: alexc on May 02, 2018, 12:13:11 pm
Hi everybogy.

I have questions about jTCPSocketClient component.

When I try asyncConnect and sendmessage it is work perfect! but if I then do CloseConnection, and then again asyncConnect, it connected, but sendmessage didn't work (

How to create a new jTCPSocketClient component in run time?

I tryed :
clientsocket := jTCPSocketClient.Create(gApp);
clientsocket.Init(gApp); 

and

clientsocket := jTCPSocketClient.Create(Self);
clientsocket.Init(gApp); 

but both crashed in clientsocket.Init(gApp);

Thank you.
Title: Re: Android Module Wizard
Post by: WayneSherman on May 05, 2018, 06:43:58 am
I have questions about jTCPSocketClient component.

Sorry I can't help you with jTCPSocketClient.  If your application can use synchronous / blocking communication calls, another option is to use Synapse (http://www.ararat.cz/synapse/doku.php/about) (see also here (http://wiki.freepascal.org/Synapse)).  It works with Android with a small modification to one file (see bug report here (https://sourceforge.net/p/synalist/bugs/43/)).

Code: Pascal  [Select][+][-]
  1. uses BlckSock;
  2.  
  3.     TCPBlockSocket := TTCPBlockSocket.Create;
  4.  
  5.     TCPBlockSocket.Bind('', cAnyPort);
  6.     TCPBlockSocket.Connect(Host, Port);
  7.     TCPBlockSocket.SendString(AString);
  8.     if TCPBlockSocket.LastError <> 0 then begin
  9.     //error handling
  10.     end;
  11.  
  12.    FreeAndNil(TCPBlockSocket);
  13.  
Title: Re: Android Module Wizard
Post by: jmpessoa on May 12, 2018, 07:22:17 am
Hello All!

There is an updated LAMW revision!

Version 0.8 - rev 01 - 12 - May- 2018

   IMPROVED/FIXED support/install to MacOs !!

      Warning: X11 [libGL.dylib] is no longer bundled with Mountain Lion (and later!)         
         [This will prevents/drops some LAMW features,
         including the use of OpenGL components "jCanvasES1" and "jCanvasES2"]


Thanks to All!

Special thanks to DonAlfredo and  A.S.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 16, 2018, 05:30:13 am
@jmpessoa

Does using old android sdk manager ( like r24/r25 ) affect to created app ?
Sometimes I see my app run well on my phone (android 5.0) but on higher it crashes ( if the app implemented internet connection components ) ( although the target api is android 6.0/7.0)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2018, 06:13:41 am
Quote
Does using old android sdk manager ( like r24/r25 ) affect to created app ?

No!  We need higher SDK only for "AppCompat" material theme...
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 16, 2018, 06:14:00 am
@jmpessoa
With lamw v0.8, i cant run app demos on my Galaxy J1 anymore (it crashes) ( it works with old lamw version )
I dont know why, I still use ndk r10e, sdk t25, set up paths needed
But building apk file runs well, and running my own app designed by lamw v0.8 works

update: I tried running your app demos on another uses android 6.0 and it still be
Title: Re: Android Module Wizard
Post by: jmpessoa on May 16, 2018, 07:07:32 am

Mybe, "D:\"

I will do some tests...

Thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 17, 2018, 06:20:05 am

Mybe, "D:\"

Yes. When I create new Lamw GUI
Below dialog appears, but i havent never seen it before ( with old lamw version )

Update: Using
 -SDK r25
 -NDK r16b
- Building and Starting Compat Theme-Used App run well
- Building is ok, but Starting Older Example Apps ( uses Ant to build ) crashes when starting
- About the dialog "....ndk/toolchains.., change to ndl/toolchains", i dont know how to solve this
Title: Re: Android Module Wizard
Post by: jmpessoa on May 17, 2018, 08:07:54 am
Hi m4u!

Use "Ctrl+C" to copy the [complete] message from dialog...

[there is some error when converting "the demo" path to your system...]
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 17, 2018, 01:06:14 pm
Hi m4u!

Use "Ctrl+C" to copy the [complete] message from dialog...

[there is some error when converting "the demo" path to your system...]

Quote
[Window Title]
Confirmation

[Content]
Path "D:\ndk_r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.9.x\" does not exist.
Change it to "D:\ndk_r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9.x\"?

[Yes] [Cancel] [Yes to All]
Title: Re: Android Module Wizard
Post by: jmpessoa on May 17, 2018, 06:57:12 pm

Hi m4u!

The wizard is trying fix your system path...

What happens if you choose [YES]?
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 18, 2018, 04:13:45 am

Hi m4u!

The wizard is trying fix your system path...

What happens if you choose [YES]?

After choosing Yes/Yes to all, everything continues and building apk file starts/lamw GUI project created successfully
but i think something was wrong, right ? . I havent seen this problem before
Title: Re: Android Module Wizard
Post by: jmpessoa on May 18, 2018, 08:36:44 am

Hi m4u!

Go to folder  "Lazarus\config"

and open the file: "JNIAndroidProject.ini"

try change the line:

PrebuildOSYS=windows

to:

PrebuildOSYS=windows-x86_64
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 18, 2018, 04:27:15 pm

Hi m4u!

Go to folder  "Lazarus\config"

and open the file: "JNIAndroidProject.ini"

try change the line:

PrebuildOSYS=windows

to:

PrebuildOSYS=windows-x86_64

Thanks
About your example apps crashes when starts ( projects dont use compat theme or relatives ), do you have somefix ?  :)
And is there some way to implement Admob into my app ?  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on May 18, 2018, 07:10:09 pm


Quote
About your example apps crashes when starts ( projects dont use compat theme or relatives ), do you have somefix ?  :)

What example?

Quote
And is there some way to implement Admob into my app ?

Ok. I will try add/implement Admod support....
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 19, 2018, 03:35:45 am


Quote
About your example apps crashes when starts ( projects dont use compat theme or relatives ), do you have somefix ?  :)

What example?

Many, I tried build and install examples like Bluetooth Demo, Asynctask Demo,...etc, but when start it on phone, the app crashes
I installed app on another but it still be,
If I build and install demos uses AppCompat Themes (Have New Lamw Icon), they runs well  :(
Title: Re: Android Module Wizard
Post by: alexc on May 22, 2018, 08:58:30 am
Hello.
It's possible do this code:

Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType(Uri.parse("file:///path_to.apk"),
                    "application/vnd.android.package-archive");


on pascal? May be with jIntentManager, but how?
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2018, 09:06:39 am


You can try some "AppIntentManagerDemos*" 

if necessary I can [try] improve the jIntentManager component!
Title: Re: Android Module Wizard
Post by: alexc on May 22, 2018, 09:18:22 am
I tryed the Demos.
But app is crashes.
maybe I'm doing something wrong.
Title: Re: Android Module Wizard
Post by: alexc on May 22, 2018, 11:53:28 am
Is there any way how to install(update)  the same application what is running, from apk file (downloaded erly)? I mean programmatically.


If I do
jIntentManager1.SetAction('android.intent.action.VIEW');
jIntentManager1.SetDataUri(jIntentManager1.ParseUri('file:///path_to_apk'));
jIntentManager1.StartActivity();

I got mesage "Cannot display PDF"

P.S.
It seems I found where the problem is. The problem is that jIntentManager1 have two procedures "SetDataUri" and "SetMimeType", but don't have procedure (java  method) SetDataAndType.
More info is here: https://stackoverflow.com/questions/13719471/why-setdataandtype-for-an-android-intent-works-fine-when-setdata-and-settype
Title: Re: Android Module Wizard
Post by: jmpessoa on May 22, 2018, 06:55:00 pm

Good info!

I will [try] implement SetDataAndType [within today]!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on May 23, 2018, 06:13:08 am

Done!

[Added "SetDataAndType" to jIntentManager ... ]

Thank you!
Title: Re: Android Module Wizard
Post by: alexc on May 23, 2018, 09:14:25 am
Thank you very much. I will try it now.
Title: Re: Android Module Wizard
Post by: alexc on May 23, 2018, 09:51:29 am
It working fine. Thank you.
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 24, 2018, 03:48:20 pm
Is AppCompatTheme not stable ?
With an ActionBarTab app using Compat Theme with NoActionBarTab option, the app will crash when opend
This doesnt happen with DefaultDeviceTheme option
Title: Re: Android Module Wizard
Post by: jmpessoa on May 24, 2018, 06:38:24 pm

Hi m4u!

AppCompat need other tabbar: jsTabBar  [or   jsViewPager]  [Android Bridges Support palette...]

for simple tab, you can use "jsViewPager" see the demo "AppCompatViewPagerDemo1"
Title: Re: Android Module Wizard
Post by: serbod on May 25, 2018, 04:58:59 pm
1. Project name with spaces cause Gradle and Java errors, related to class name.
For example, <manifest package="org.lamw.My project" />

2. Hidden project options in controls.lpi, <CustomData />, project can't migrate to other system.

3.  src\org\lamw\myproject\*.java not re-created on build. For example, I copy some jForm (lfm + pas) from other project, and get runtime error:

Quote
I/dalvikvm(21351): java.lang.NoSuchMethodError: no method with name='jTimer_Create' signature='(J)Ljava/lang/Object;' in class Lorg/lamw/myproject/Controls;

4. Lack of properties for related controls (widgets). For example, setting jForm.ActionBarTitle to abtTextAsTitle cause runtime error, that ActionBar not found. And there no property to assign ActionBar or it's name/id. Same for other related controls - AppBarLayout, TabLayout, ViewPager...

5. Context menu - Change parent is not active, parent can be changed only by editing .lfm
Title: Re: Android Module Wizard
Post by: jmpessoa on May 25, 2018, 05:32:06 pm

Hello, serbod!

I will try some fixes...

thank you!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on May 30, 2018, 06:16:38 pm
@jmpessoa
jLocation crashes on Android 6.0 and higher
I tested, it works well on Android 5.x and below
Or because i use ndk r10e ?  :o
Title: Re: Android Module Wizard
Post by: jmpessoa on May 31, 2018, 12:55:13 am
Hi m4u!

I think your system need some "cleanup"!!!

1) you can try  "cleanup" your app project: Open your project and then

Lazarus IDE: "Run" --> "Clean up and Build..."

2) if not working [yet],  you can try  "cleanup" the LAMW packages:

Lazarus IDE: "Packages" --> "Open Package File (.lpk)"
 
Select some/all LAWM package then:

--> "More" --> "Recompile Clean"     

and

--> "Use" --> "Install"

and then (1) again..
Title: Re: Android Module Wizard
Post by: rx3.fireproof on May 31, 2018, 10:53:58 pm
Hello jmpessoa

Thanks for excellent work.

There's a little problem in  Lawn version 0.8.

For Android 6 and higher  after install app need to manually enable the permissions in system  or use exceptions in code.

example for white/read permissions

Code: Pascal  [Select][+][-]
  1.  
  2. try
  3.  
  4. //code...
  5.  
  6.  stringlist_text.SaveToFile(Self.GetEnvironmentDirectoryPath(dirSdCard) + 'mydir' + '/' +'myfile.txt';
  7.  
  8. //code...
  9.  
  10. except
  11.  
  12.         showmessage('no write/read permission');
  13.    
  14.   end;      


Otherwise, the application will crash.

I have everything works on the following settings:

Windows-x86,
Lazarus Android Module Wizard 0.8.1,
laz4android 1.8, FPC  3.0.4,
Java JDK 1.8 update 171,
Android SDK Build-Tools 27.0.3
Android NDK r17,
min SDK version 15,
target SDK version 27, 
Ant 1.10.3. 

best regards

rx3.fireproof

p.s.
to manually change settings for other builds it's hard :-[       


   






Title: Re: Android Module Wizard
Post by: jmpessoa on June 01, 2018, 12:22:46 am

Hi rx3.fireproof!

[welcome back!]

Quote
For Android 6 and higher ....

Quote
use exceptions in code....

Good Info!

Thank you!
Title: Re: Android Module Wizard
Post by: alexc on June 12, 2018, 11:10:54 am
Hello.

I have a Pervasive database and Pervasive JDBC Driver (The Pervasive PSQL JDBC driver is a Type 4, 100% Pure Java certified client driver. The driver supports the JDBCTM 2.0 standard. The driver works on all platforms that support the JVM.).

How can I used it in LAMW, if it's possible?
Title: Re: Android Module Wizard
Post by: abssistemas on June 21, 2018, 03:19:41 pm
Hello,

How do I publish an apk in google play?

Title: Re: Android Module Wizard
Post by: Leledumbo on June 22, 2018, 12:25:41 am
Hello,

How do I publish an apk in google play?
Follow this guide (https://medium.com/mindorks/upload-your-first-android-app-on-play-store-step-by-step-ee0de9123ac0). Note: prepare your credit card.
Title: Re: Android Module Wizard
Post by: Almir Lima on June 26, 2018, 12:53:54 am
I'm study the project, i'm compiling the demos, but any sometimes not work or not Compil, like the component of the Camera and any of TAB ( Android Bridges Support ).

When i use the button, Take photo. The APP stop.

I have using Android 6.0 ( API 23 ), SDK 28.0.0,  jdk1.8.0_171 and i execute it in Phone with Android 8.0.

I have ones questions.
What´s ANT and GRADLE?

What's the minimum version to execute the App make with the tool?

Title: Re: Android Module Wizard
Post by: jmpessoa on June 26, 2018, 02:04:12 am

Hello Almir!

Quote
What´s ANT and GRADLE?

Ant and Gradle are builder-systems to compile and "build" android APK

You need Gradle  when select "AppCompat" themes and "Android Bridges Support" palete/components...

but for simple/default projects Ant is ok...
Title: Re: Android Module Wizard
Post by: Almir Lima on June 26, 2018, 04:20:51 am
exist a method to configure the IDE to use two version of compiler, ARM and WIN 32 like a Delphi. would like compile projects Windows and Projects Android without have use other instance of IDE.

Parabéns pelo trabalho Pessoa.
Title: Re: Android Module Wizard
Post by: jmpessoa on June 26, 2018, 04:52:55 am

Ola Almir!

A good solution is install "laz4android"

https://sourceforge.net/projects/laz4android/

(laz4android =  lazarus for windows + cross compile for android)

More info here: https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/LAMW%20Getting%20Started.txt
Title: Re: Android Module Wizard
Post by: BjPascal on July 16, 2018, 12:55:19 am
using Lazarus 1.9.0 and FPC 3.1.1 on Win7 x64

Installing LAMW with OPM failed to compile amw_ide_tools
and reports:
   Cannot install package: "amw_ide_tools.lpk"

Any idea how to fix it ?
Title: Re: Android Module Wizard
Post by: jmpessoa on July 16, 2018, 04:48:00 am

Hi BjPascal!

Please, try to install from:

https://github.com/jmpessoa/lazandroidmodulewizard

Thank you!
Title: Re: Android Module Wizard
Post by: sameer on July 18, 2018, 10:50:00 am
Hi,

I am using LAMW + Win32 + Laz4Android + SDK27 + NDK24 + JDK1.8.

The AppDBGridView example compiles and works fine on emulator. However, if i create a new project which contains component DBGridview then i get the following error :

Code: Diff  [Select][+][-]
  1. Panic:     [javac] d:\lamw\PoS_Mad\src\org\lamw\pos_mad\android-27\jDBListView.java:90: error: cannot find symbol

Please advice.
Title: Re: Android Module Wizard
Post by: jmpessoa on July 18, 2018, 09:30:11 pm

Hi sameer!

Look for "jDBListView.java" in  LAMW folder "......\java\lamwdesigner"

if  the file exists then delete  the jDBListView componet from Form designer
and do  "run->build"

Now put again the jDBListView componet  in the form...
and do  "run->build"
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2018, 06:27:02 am
Hi All,

There is a  new LAMW revision!

Version 0.8 - rev 02 - 21 - August - 2018

NEW! Added support to App "Runtime Permission" [Required by "target" Api >= 23]

UPDATED!! demo "AppCameraDemo"  ["Runtime Permission" example...]

NEW!  jsAdMob component [thanks to TR3E]
           warning: Need "AppCompat" theme...

NEW demo "AppCompatAdMobDemo1"


Thansk to All
Title: Re: Android Module Wizard
Post by: DonAlfredo on August 22, 2018, 07:26:54 am
Quote
NEW! Added support to App "Runtime Permission" [Required by "target" Api >= 23]
Very important feature on new Androids ! Thanks very much !!
Title: Re: Android Module Wizard
Post by: jmpessoa on August 26, 2018, 07:38:50 am
Hi All!

UPDATED!! LAMW demos:

"AppLocationDemo1" 
"AppSMSDemo1" 

["Runtime Permission" example... targeting API >= 23]
Title: Re: Android Module Wizard
Post by: CC on August 27, 2018, 08:53:51 am
jmpessoa,

Stability is very important and I figured it is probably best to use the same/closest possible version to what you are working with.
But I am confused about which SDK and build/tools/platform-tools/build-tools  version to use with LAMW.

http://wiki.lazarus.freepascal.org/LAMW says that R24.4.1.  But SDK manager does not recognize this version and the downloaded zip file does not seem to contain all files needed to work out of the box.

Is there any risk using a more recent NDK?

Title: Re: Android Module Wizard
Post by: jmpessoa on August 27, 2018, 05:57:38 pm
Hi,  CC!

1) For not "AppCompat" themes  you can use/target any recent API .... [warning: the R24.4.1 is the last that support "ant" builder]   ... Recommended: target 21 or 22 [not run permission is required !!!]

2) Yes, R24.4.1  [or any...] is not "complete" out of box...

[from "LAMW getting started.txt"]
                1)after unpacked [R24.4.1 or any...], open a terminal and go to "sdk/tools"  folder
      2)run  cmd "android sdk" to open a GUI "SDK Manager"
      3)check "Android SDK Tools"
      4)check "Android SDK Platform-Tools"
      
      5)check "Android SDK Build-Tools 25.0.3" [need for "gradle" builder]    

      5.1)check  "Android SDK Build-Tools 26.0.2"  [need for "gradle" builder]
      
      6)go to "Android 7.1.1 (API 25)" and check  "SDK Platform" [need for "AppCompat" themes and "gradle" builder]

      7)go to "Extras" and check:
            "Android Support Repository"            
            "Android Support Library"            
            "Google USB Drive"
 
3) For "AppCompat" themes the only "recommended"  for LAMW:

"Android SDK Build-Tools 25.0.3" [need by old "gradle" plugin]    
"Android SDK Build-Tools 26.0.2"  [need by 3.0.1  "gradle" plugin ...]
"Android 7.1.1 (API 25)"
"Extras":          "Android Support Repository"            
            "Android Support Library"            
 
Title: Re: Android Module Wizard
Post by: abssistemas on August 30, 2018, 01:41:10 pm
Hello

I'm using the jTCPSocketClient component in an android project and need to send a 1024 bytes sequence, but it can not send bytes, only string by the jTCPSocketClient.SendMessage command.
It would have a way to send bytes instead of text.

Thank you.
Title: Re: Android Module Wizard
Post by: Handoko on August 30, 2018, 02:29:38 pm
You can write you own functions for converting bytes to text string and the opposite.

I ever read the discussion about it but I forgot where to find it.
Title: Re: Android Module Wizard
Post by: abssistemas on August 30, 2018, 02:50:59 pm
does not work because the SendMessage command does not send bytes that are not valid characters, such as '$00', '$0A'.
Title: Re: Android Module Wizard
Post by: Handoko on August 30, 2018, 02:54:30 pm
Not I didn't mean like that.

You convert a char $0A to become a string that contains 2 characters '0A'.

This trick is useful for transmitting binary data as human-readable text, read more:
https://en.wikipedia.org/wiki/Base64
Title: Re: Android Module Wizard
Post by: abssistemas on August 30, 2018, 03:03:07 pm
I understood, but then I would have to convert inside my firmware again, I did not want that.
The bluetoothclientsocket.pas file sends text and bytes, with the WriteMessage and write method respectively. Would you be able to implement the write method in the tcpsocketclient.pas file?
Title: Re: Android Module Wizard
Post by: Handoko on August 30, 2018, 03:27:41 pm
It doesn't seem hard to implement but unfortunately I'm not familiar with network programming.

You can make a feature request. But if you need the feature to be implemented quickly, you can consider to create a bounty for it:
http://wiki.freepascal.org/Bounties
Title: Re: Android Module Wizard
Post by: abssistemas on August 30, 2018, 03:35:46 pm
Okay, thanks for the help.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 30, 2018, 05:14:23 pm

Hi abssistemas!

Can you try  "procedure SendFile(fullPath: string) ...?
Title: Re: Android Module Wizard
Post by: jmpessoa on September 01, 2018, 09:03:48 am
 @Horas
Quote
I would like to upload an image file to my http server using httpclient post, Can you help me.
jHttpClient looks like doesn't support file upload, please can you provide me with an example code to upload file or image from the android mobile to http server

Done!!!

Added method "UploadFile" to jHttpClient!
[demo "AppHttpClientDemo3"]

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on September 03, 2018, 08:04:55 am
@abssistemas

Quote
I'm using the jTCPSocketClient component in an android project and need to send a 1024 bytes sequence, but it can not send bytes, only string by the jTCPSocketClient.SendMessage command.
It would have a way to send bytes instead of text.

Done! 

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton2Click(Sender: TObject);
  2. var
  3.   data: TDynArrayOfJByte;
  4. begin
  5.   SetLength(data, 2);
  6.   data[0]:= $0A;
  7.   data[1]:= $00;
  8.  
  9.   if  FConnected then
  10.       jTCPSocketClient1.SendBytes(data, True);
  11.  
  12.            //"True" will write FIRST the Len=2 to the Server ...
  13.            //"False" will write only the "data" to the Server ...
  14.  
  15.    SetLength(data, 0);
  16. end;  
  17.  
Title: Re: Android Module Wizard
Post by: abssistemas on September 03, 2018, 01:52:37 pm
I'm using version 0.7.0, how do I upgrade to 0.8.0, so I can test? I tried updating online but did not upgrade.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 03, 2018, 06:37:14 pm

Well,  the "ideal" is to install a "git" client,
so you can "update/synchronize"  your system...

But,  You can, too,  "download" as zip e reinstall/replace all packages/folders..

   .Install order.

      tfpandroidbridge_pack.lpk   [..../android_bridges]
      lazandroidwizardpack.lpk   [..../android_wizard]
      amw_ide_tools.lpk      [..../ide_tools]

Title: Re: Android Module Wizard
Post by: CC on September 05, 2018, 05:26:04 pm
Hi,  CC!

1) For not "AppCompat" themes  you can use/target any recent API .... [warning: the R24.4.1 is the last that support "ant" builder]   ... Recommended: target 21 or 22 [not run permission is required !!!]

2) Yes, R24.4.1  [or any...] is not "complete" out of box...

[from "LAMW getting started.txt"]
                1)after unpacked [R24.4.1 or any...], open a terminal and go to "sdk/tools"  folder
      2)run  cmd "android sdk" to open a GUI "SDK Manager"
      3)check "Android SDK Tools"
      4)check "Android SDK Platform-Tools"
      
      5)check "Android SDK Build-Tools 25.0.3" [need for "gradle" builder]    

      5.1)check  "Android SDK Build-Tools 26.0.2"  [need for "gradle" builder]
      
      6)go to "Android 7.1.1 (API 25)" and check  "SDK Platform" [need for "AppCompat" themes and "gradle" builder]

      7)go to "Extras" and check:
            "Android Support Repository"            
            "Android Support Library"            
            "Google USB Drive"
 
3) For "AppCompat" themes the only "recommended"  for LAMW:

"Android SDK Build-Tools 25.0.3" [need by old "gradle" plugin]    
"Android SDK Build-Tools 26.0.2"  [need by 3.0.1  "gradle" plugin ...]
"Android 7.1.1 (API 25)"
"Extras":          "Android Support Repository"            
            "Android Support Library"

Thanks!
Title: Re: Android Module Wizard
Post by: abssistemas on September 06, 2018, 03:02:05 pm
Well,  the "ideal" is to install a "git" client,
so you can "update/synchronize"  your system...

But,  You can, too,  "download" as zip e reinstall/replace all packages/folders..

   .Install order.

      tfpandroidbridge_pack.lpk   [..../android_bridges]
      lazandroidwizardpack.lpk   [..../android_wizard]
      amw_ide_tools.lpk      [..../ide_tools]

I compiled tfpandroidbridge_pack.lpk and it worked, but when I tried to compile the lazandroidwizardpack.lpk it gave error as follows:

Mensagens
Verbose: Selected chip architecture: armeabi-v7a
Verbose: Taking libraries from folder: c:\Agenor\Lazarus\GS4\libs\armeabi-v7a
Verbose: Found library: libcontrols.so
Hint: (11030) Start of reading config file c:\laztoapk\downloads\laz4android1.8\fpc\3.0.4\bin\i386-win32\fpc.cfg
Hint: (11031) End of reading config file c:\laztoapk\downloads\laz4android1.8\fpc\3.0.4\bin\i386-win32\fpc.cfg
Free Pascal Compiler version 3.0.4 [2017/12/07] for arm
Copyright (c) 1993-2017 by Florian Klaempfl and others
(1002) Target OS: Android for ARMEL
(3104) Compiling lcl.pas
(3104) Compiling C:\laztoapk\downloads\laz4android1.8\lcl\interfaces\gtk2\alllclintfunits.pas
(3104) Compiling C:\laztoapk\downloads\laz4android1.8\lcl\interfaces\gtk2\gtk2cellrenderer.pas
(3104) Compiling C:\laztoapk\downloads\laz4android1.8\lcl\interfaces\gtk2\gtk2int.pas
C:\laztoapk\downloads\laz4android1.8\lcl\interfaces\gtk2\gtk2int.pas(37,6) Fatal: (10022) Can't find unit XLib used by Gtk2Int
Fatal: (1018) Compilation aborted
Error: c:\laztoapk\downloads\laz4android1.8\fpc\3.0.4\bin\i386-win32\ppcrossarm.exe returned an error exitcode
Title: Re: Android Module Wizard
Post by: jmpessoa on September 06, 2018, 04:58:35 pm

@abssistemas

Before you try (re)instal any package you need open a default windows project in Lazarus....

[if a LAMW project is open in the IDE...  you can get some strange error!!!]
Title: Re: Android Module Wizard
Post by: abssistemas on September 07, 2018, 01:17:12 pm
Okay, now it worked.
I have another problem now. When I send an array of 1024 bytes using the method, jTCPSocketClient1.SendBytes (data, False); it works normally, but soon after sending the bytes the connection is lost, and I do not get any more data through the socket. I have to connect again. The jTCPSocketClient1.SendMessage method remains connected without problems.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 07, 2018, 06:20:52 pm

@abssistemas

OK. I will improve  "jTCPSocketClient"  SendBytes!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on September 08, 2018, 05:22:19 am
Hi  abssistemas!

Attached is a new java template .....

Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

Please,  test the "SendBytes" and also the "SendMessage"

Thank you!!!
Title: Re: Android Module Wizard
Post by: DelphiFreak on September 09, 2018, 11:49:24 am
Hello,

I have a wish for the next version.
Could you place a button like this (see attachment).

It would open the explorer at the location of the .apk-file.

As I found here https://www.askingbox.com/question/lazarus-open-folder-in-explorer (https://www.askingbox.com/question/lazarus-open-folder-in-explorer) it should be easy.

OpenDocument('C:\Example');

Thank you.


Title: Re: Android Module Wizard
Post by: A.S. on September 09, 2018, 07:34:31 pm
Hello,

I have a wish for the next version.
Could you place a button like this (see attachment).

It would open the explorer at the location of the .apk-file.

As I found here https://www.askingbox.com/question/lazarus-open-folder-in-explorer (https://www.askingbox.com/question/lazarus-open-folder-in-explorer) it should be easy.

OpenDocument('C:\Example');

Thank you.
Not sure "Android emulators" window is a correct place for such button. This dialog is intended to start AVDs. If some AVD is already started (or real devices is connected via USB), this dialog won't be shown.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 10, 2018, 06:04:25 am

Hi All,

About "ide-tools" package:

the menu option "[LAMW] Android Module Wizard" 

now can:

"Convert the Project to AppCompat Theme"

and

"Use/Import LAMW Stuff..."    [form reuse!!!]

Thanks to All!
Title: Re: Android Module Wizard
Post by: abssistemas on September 10, 2018, 01:47:03 pm
Hi  abssistemas!

Attached is a new java template .....

Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

Please,  test the "SendBytes" and also the "SendMessage"

Thank you!!!

I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 10, 2018, 07:55:31 pm
@abssistemas

[jTCPSocketClient componet]
Quote
I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.

Thank you!!!
Title: Re: Android Module Wizard
Post by: abssistemas on September 22, 2018, 04:48:41 pm
@abssistemas

[jTCPSocketClient componet]
Quote
I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.

Thank you!!!

I need to now get bytes from the jTCPSocketClient component, because the OnMessagesReceived event returns an array of string and would have to be an array of bytes.
Would you be able to modify the component to receive bytes instead of string?
Title: Re: Android Module Wizard
Post by: jmpessoa on September 23, 2018, 07:32:38 am
Quote
Would you be able to modify the component to receive bytes instead of string?

Done!!!

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModuleTCP.jButton1Click(Sender: TObject);
  2. begin
  3.  
  4.   //NEW!!! Prepare to "Send" and "Receive"  bytes
  5.   jTCPSocketClient1.SetDataTransferMode(dtmByte);  
  6.  
  7.   jTCPSocketClient1.ConnectAsync('192.168.0.105', 54321);
  8. end;
  9.  


Code: Pascal  [Select][+][-]
  1. //Handle Bytes Received ....
  2. procedure TAndroidModuleTCP.jTCPSocketClient1BytesReceived(Sender: TObject;
  3.   var bytesReceived: TDynArrayOfJByte);
  4. var
  5.    i, count: integer;
  6. begin
  7.    count:=  Length(bytesReceived);
  8.    for i:= 0 to count-1 do
  9.    begin
  10.       ShowMessage(IntToStr(bytesReceived[i]))
  11.    end;
  12. end;
  13.  

Please, test it!!

Thank you!
Title: Re: Android Module Wizard
Post by: abssistemas on September 24, 2018, 02:58:20 pm
Quote
Would you be able to modify the component to receive bytes instead of string?

Done!!!

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModuleTCP.jButton1Click(Sender: TObject);
  2. begin
  3.  
  4.   //NEW!!! Prepare to "Send" and "Receive"  bytes
  5.   jTCPSocketClient1.SetDataTransferMode(dtmByte);  
  6.  
  7.   jTCPSocketClient1.ConnectAsync('192.168.0.105', 54321);
  8. end;
  9.  


Code: Pascal  [Select][+][-]
  1. //Handle Bytes Received ....
  2. procedure TAndroidModuleTCP.jTCPSocketClient1BytesReceived(Sender: TObject;
  3.   var bytesReceived: TDynArrayOfJByte);
  4. var
  5.    i, count: integer;
  6. begin
  7.    count:=  Length(bytesReceived);
  8.    for i:= 0 to count-1 do
  9.    begin
  10.       ShowMessage(IntToStr(bytesReceived[i]))
  11.    end;
  12. end;
  13.  

Please, test it!!

Thank you!

I tested but it crashed when I connected it.
Without the jTCPSocketClient1.SetDataTransferMode (dtmByte) command it works normally.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 24, 2018, 06:46:12 pm

Hi  abssistemas!

Attached is a new java template .....  I fixed "SetDataTransferMode"


Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

Please,  test the "SendBytes/OnBytesReceive" and also the "SendMessage/OnMessagesReceived"

Thank you!!!
Title: Re: Android Module Wizard
Post by: abssistemas on September 25, 2018, 01:08:12 pm
Hi jmpessoa

I tested the modification but it did not work.

No more crash.

"SendMessage / OnMessagesReceived" works.
"SendBytes" works.
"OnBytesReceive" does not work does not receive anything.
Here's my code:


type

  { TAndroidModuleMaps }

  TAndroidModuleMaps = class(jForm)
    procedure jButton2Click(Sender: TObject);
    procedure jTCPSocketClient1Connected(Sender: TObject);
    procedure jTCPSocketClient1MessagesReceived(Sender: TObject;
      messagesReceived: array of string);
    procedure jTCPSocketClient1BytesReceived(Sender: TObject;
      var bytesReceived: TDynArrayOfJByte);


procedure TAndroidModuleMaps.jButton2Click(Sender: TObject);
begin
  //NEW!!! Prepare to "Send" and "Receive"  bytes
  jTCPSocketClient1.SetDataTransferMode(dtmByte);

  jTCPSocketClient1.ConnectAsync('192.168.15.5',1024);

end;

procedure TAndroidModuleMaps.jTCPSocketClient1MessagesReceived(Sender: TObject;
  messagesReceived: array of string);
begin
  //aqui funciona
  ShowMessage('Recebido string');
end;


procedure TAndroidModuleMaps.jTCPSocketClient1BytesReceived(Sender: TObject;
  var bytesReceived: TDynArrayOfJByte);
begin
  //aqui não funciona
   ShowMessage('Recebido bytes');
end;

Title: Re: Android Module Wizard
Post by: jmpessoa on September 26, 2018, 04:29:34 am

Hi  abssistemas!

Attached is a new java template ..... 

Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

I just inserted some "debug" tags...

Please,  keep this:

jTCPSocketClient1.SetDataTransferMode(dtmByte);
jTCPSocketClient1.ConnectAsync(....);

and test the "SendBytes"  ......

for debug,  "OnBytesReceive"  will try report  only 2  jbytes ....

"0" and "0"

OR

"-1" and "-1"

OR
 
of course, the bytes reported by your system...

You can report your test here...

Thank you!
Title: Re: Android Module Wizard
Post by: abssistemas on September 26, 2018, 12:42:57 pm
Hi jmpessoa,

You have not appended the java file.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 26, 2018, 06:20:19 pm

Sorry...  Fixed here!
Title: Re: Android Module Wizard
Post by: abssistemas on September 27, 2018, 04:23:57 pm
With this line

jTCPSocketClient1.SetDataTransferMode(dtmByte);

It did not send, but without it is sending only string
Title: Re: Android Module Wizard
Post by: abssistemas on September 29, 2018, 02:17:53 pm

Sorry...  Fixed here!

Hi jmpessoa,

Is it missing to create the TOnBytesReceived event in my project?
The jTCPSocketClient component does not have the TOnBytesReceived event on it, only the TOnConnected and TOnMessagesReceived events.
I'm declaring it right, see what I've done:

type

  { TAndroidModuleMaps }
    procedure jButton2Click(Sender: TObject);
    procedure jTCPSocketClient1BytesReceived(Sender: TObject;
      var bytesReceived: TDynArrayOfJByte);


procedure TAndroidModuleMaps.jButton2Click(Sender: TObject);
begin
  //NEW!!! Prepare to "Send" and "Receive"  bytes
  jTCPSocketClient1.SetDataTransferMode(dtmByte);
  jTCPSocketClient1.ConnectAsync('192.168.15.5',1024);
end;

procedure TAndroidModuleMaps.jTCPSocketClient1BytesReceived(Sender: TObject;
  var bytesReceived: TDynArrayOfJByte);
begin
  //is not showing this message
   ShowMessage('Received bytes');
end;




Title: Re: Android Module Wizard
Post by: jmpessoa on September 29, 2018, 06:51:10 pm

Quote
The jTCPSocketClient component does not have the TOnBytesReceived event on it,

You need to upgrade the LAMW from github!!

this event  was added 6 days ago!

added here:
"tcpsocketclient.pas"
"laz_and_controls_events.pas"
Title: Re: Android Module Wizard
Post by: Segator on September 30, 2018, 02:41:38 am
Hi jmpessoa how i can read my old sms saved in the phone with LAMW?, i see the AppSMSDemo1 and AppSMSWidgetProviderDemo1 but this only read the incoming sms and i need read all sms saved.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 30, 2018, 07:50:48 pm
@Segator

Quote
i need read all sms saved.....

Ok. I will try some solution!

Thank you!
Title: Re: Android Module Wizard
Post by: Segator on October 01, 2018, 02:47:33 am
Thanks jmpessoa i appreciate it
Title: Re: Android Module Wizard
Post by: abssistemas on October 04, 2018, 01:37:16 pm

Quote
The jTCPSocketClient component does not have the TOnBytesReceived event on it,

You need to upgrade the LAMW from github!!

this event  was added 6 days ago!

added here:
"tcpsocketclient.pas"
"laz_and_controls_events.pas"


With the lamw update o  jTCPSocketClient worked perfectly, congratulations.

I'm having a new problem with the jActionBarTab component.

It is not working on android oreo 8.0, closes the application. In sdk target 22 it works, but  26 or 27 does not.

If I run on android 7 or smaller runs smoothly.

Thank you for your effort and dedication.
Title: Re: Android Module Wizard
Post by: abssistemas on October 06, 2018, 05:38:56 pm

With the lamw update o  jTCPSocketClient worked perfectly, congratulations.

I'm having a new problem with the jActionBarTab component.

It is not working on android oreo 8.0, closes the application. In sdk target 22 it works, but  26 or 27 does not.

If I run on android 7 or smaller runs smoothly.

Thank you for your effort and dedication.

Solved the problem with the jActionBarTab component using the target sdk 24 or 25.

Title: Re: Android Module Wizard
Post by: abssistemas on October 15, 2018, 02:35:37 pm

With the lamw update o  jTCPSocketClient worked perfectly, congratulations.

I'm having a new problem with the jActionBarTab component.

It is not working on android oreo 8.0, closes the application. In sdk target 22 it works, but  26 or 27 does not.

If I run on android 7 or smaller runs smoothly.

Thank you for your effort and dedication.

Solved the problem with the jActionBarTab component using the target sdk 24 or 25.

Hi, jmpessoa.

What do I do to run the jActionBarTab component on sdk 26 since google play does not support sdk versions smaller than 26?
Title: Re: Android Module Wizard
Post by: jmpessoa on October 20, 2018, 04:14:02 am

Hi, Segator!

There is a new "jSMSManager" component
 
and a new demo "AppSMSManagerDemo1"

Now you can read all sms inbox!

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 24, 2018, 12:01:09 am
@abssistemas

Quote
What do I do to run the jActionBarTab component on sdk 26 since google play does not support sdk versions smaller than 26?

Fixed!

Please,  update the LAMW framework from github and re-install the packages:
"tfpandroidbridge_pack.lpk" and  "lazandroidwizardpack.lpk"


Thank you!
Title: Re: Android Module Wizard
Post by: bobkos on October 27, 2018, 04:12:13 pm
@jmpessoa

Thank you for your great efforts for LAMW developing and all other contributors.
May I ask about jListView in version 0.8, (because before update it was ok), why when is in the line exist "(" or ")" it going to display as is attached one.

Thank you in advance.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 27, 2018, 10:43:52 pm

Hi, bobkos!

jListView has some default tokens  delimiters for line text formatation purposes...

but, you can change the defaults....

procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
  jListView1.SetLeftDelimiter('{');
  jListView1.SetRightDelimiter('}');;
end;
Title: Re: Android Module Wizard
Post by: bobkos on October 28, 2018, 02:40:33 am
Hi, jmpessoa!

Thank you very much, now it's clear!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 06, 2018, 04:33:15 am
hi
@jmpessoa , is there someway to use MQTT in lamw ?  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on November 06, 2018, 04:47:07 am


Yes!

https://play.google.com/store/apps/details?id=com.abs.cell500p&hl=en
[by @abssistema]


But, I dont have a pascal implementation.  Maybe @abssistema can help you! 
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 07, 2018, 10:02:59 am
@jmpessoa
Today i built a location app, it seems be the code:

Code: Pascal  [Select][+][-]
  1. url:=jLocation1.GetGoogleMapsUrl(lat,lng);
  2. jWebview1.Navigation(url);

cant be used anymore. Google page shows that "You must use an API key to Google Maps Platform". :) :)

And I realize that jWebview hasnt scroll  :o :o ?
Title: Re: Android Module Wizard
Post by: Leledumbo on November 08, 2018, 02:48:32 am
@jmpessoa
Today i built a location app, it seems be the code:

Code: Pascal  [Select][+][-]
  1. url:=jLocation1.GetGoogleMapsUrl(lat,lng);
  2. jWebview1.Navigation(url);

cant be used anymore. Google page shows that "You must use an API key to Google Maps Platform". :) :)

And I realize that jWebview hasnt scroll  :o :o ?
The code is 2 years old. I believe last year google maps started to lose its free (as in no API key needed) service. Today even your free calls require an API key, with limited number of calls per day (not really remember how many, probably 1000). The code definitely needs an update.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 09, 2018, 06:39:16 am

About "jLocation" component and "AppLocationDemo1":

Fixed and updated!

Please, set the new property "GoogleMapsApiKey"

Thanks!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on November 10, 2018, 11:14:44 am

About "jLocation" component and "AppLocationDemo1":

Fixed and updated!

Please, set the new property "GoogleMapsApiKey"

Thanks!

@jmpessoa, thanks for updating  :) :)
but how can we set scrolldown property for jWebView ?  :)
Title: Re: Android Module Wizard
Post by: jmpessoa on November 18, 2018, 10:11:02 pm
Hi, m4u!

I did this test:

jWebView1.Navigate('http://forum.lazarus-ide.org/index.php?action=forum');     

and the  jWebView  "scrolling"  is  OK!
Title: Re: Android Module Wizard
Post by: abssistemas on November 30, 2018, 02:30:10 pm
Hi, can anyone help me how to create a TCPSocketClient component at runtime?
Thank you!
Title: Re: Android Module Wizard
Post by: abssistemas on November 30, 2018, 02:32:25 pm
sorry the correct name is jTCPSocketClient
Title: Re: Android Module Wizard
Post by: jmpessoa on December 01, 2018, 08:15:18 pm
Quote

 how to create a jTCPSocketClient component at runtime?

You can try mimic this code:
[note that you will necessarily need an component of the same type on the form!!!]

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\lamw\workspace\AppNiceProject1\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, tcpsocketclient;
  10.  
  11. type
  12.  
  13.   { TAndroidModule1 }
  14.  
  15.   TAndroidModule1 = class(jForm)
  16.     jButton1: jButton;
  17.     jTCPSocketClient1: jTCPSocketClient;
  18.     jTextView1: jTextView;
  19.     procedure AndroidModule1Create(Sender: TObject);
  20.     procedure jButton1Click(Sender: TObject);
  21.     procedure jTCPSocketClient1BytesReceived(Sender: TObject;
  22.       var jbytesReceived: TDynArrayOfJByte);
  23.     procedure jTCPSocketClient1Connected(Sender: TObject);
  24.  
  25.   private
  26.     {private declarations}
  27.     IsNewStuffCreated: boolean;
  28.   public
  29.     {public declarations}
  30.    jButtonRuntime: jButton;
  31.    jTCPSocketClientRuntime: jTCPSocketClient;
  32.   end;
  33.  
  34. var
  35.   AndroidModule1: TAndroidModule1;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41.  
  42. { TAndroidModule1 }
  43.  
  44. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  45. begin
  46.    if (Sender as jButton).Tag = 1 then
  47.    begin
  48.  
  49.      if not IsNewStuffCreated then
  50.      begin
  51.  
  52.        jButtonRuntime:= jButton.Create(Self);  //pascal side button
  53.        jButtonRuntime.Tag:= 2;
  54.        jButtonRuntime.Text:= 'jButtonRuntime';
  55.        jButtonRuntime.LayoutParamWidth:= lpHalfOfParent;
  56.        jButtonRuntime.Anchor:= jButton1;
  57.        jButtonRuntime.PosRelativeToAnchor:= [raBelow];
  58.        jButtonRuntime.PosRelativeToParent:= [rpCenterHorizontal];
  59.        jButtonRuntime.OnClick:= jButton1Click;  //delphi mode...
  60.        jButtonRuntime.Init(gApp);    //java side button
  61.  
  62.        jTCPSocketClientRuntime:= jTCPSocketClient.Create(Self);
  63.        jTCPSocketClientRuntime.Tag:= 2;
  64.        jTCPSocketClientRuntime.OnConnected:= jTCPSocketClient1Connected;
  65.        jTCPSocketClientRuntime.OnBytesReceived:= jTCPSocketClient1BytesReceived;
  66.        jTCPSocketClientRuntime.Init(gApp);
  67.  
  68.        IsNewStuffCreated:= True; // <-----
  69.  
  70.      end
  71.      else
  72.      begin
  73.        ShowMessage('Warning: jButtonRuntime was created!');
  74.      end;
  75.  
  76.    end;
  77.  
  78.    if (Sender as jButton).Tag = 2 then
  79.    begin
  80.       ShowMessage('Hello from created jButtonRuntime !!!');
  81.    end;
  82.  
  83. end;
  84.  
  85. procedure TAndroidModule1.jTCPSocketClient1BytesReceived(Sender: TObject;
  86.   var jbytesReceived: TDynArrayOfJByte);
  87. begin
  88.  
  89.    if (Sender as jTCPSocketClient).Tag = 1 then
  90.    begin
  91.  
  92.    end;
  93.  
  94.    if (Sender as jTCPSocketClient).Tag = 2 then
  95.    begin
  96.  
  97.    end;
  98.  
  99. end;
  100.  
  101. procedure TAndroidModule1.jTCPSocketClient1Connected(Sender: TObject);
  102. begin
  103.  
  104.    if (Sender as jTCPSocketClient).Tag = 1 then
  105.    begin
  106.  
  107.    end;
  108.  
  109.    if (Sender as jTCPSocketClient).Tag = 2 then
  110.    begin
  111.  
  112.    end;
  113.  
  114. end;
  115.  
  116. procedure TAndroidModule1.AndroidModule1Create(Sender: TObject);
  117. begin
  118.   jButton1.Tag:= 1;
  119.   jTCPSocketClient1.Tag:= 1;
  120.   IsNewStuffCreated:= False;
  121. end;
  122.  
  123. end.
  124.  

Here is a good place to create/modify  java stuff,  too ...
Code: [Select]
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin

end;

Title: Re: Android Module Wizard
Post by: abssistemas on December 03, 2018, 02:04:40 pm
It worked perfectly.
Now how do I make my android application run in the background?
Title: Re: Android Module Wizard
Post by: Adromir on December 28, 2018, 05:15:34 am
I am trying to get it Run according to the Install instructions on the Wiki but its totally unsuccessfull i get a lot of Errors that fr example folders are empty or paths don't match although i made it step by step exactly how the Wiki describes it. Can anyone help me? Maybe there is something new required not Mentioned in the Wiki?
Title: Re: Android Module Wizard
Post by: jmpessoa on December 28, 2018, 06:19:36 pm

Try this:

https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/LAMW%20Getting%20Started.txt
Title: Re: Android Module Wizard
Post by: Adromir on December 30, 2018, 07:13:32 pm
Thanks I got it Running with that. Still got an Access- Violation when i opened and importet a Project, but still worked when i ignored that. Maybe a few suggestions:

1. Could the Install Cross Compile Wizard save the Location of the Source? I mean its not needed often, but a bit annoying when you start to setup your environment
And another Hint maybe for the Setupinstructions: Apparently Gradle sometimes need a properly set JAVA_HOME variable. Compiling didn't work on my system at the beginning (WIN10), because I also had JDK10 installed
2. I believe FPC Trunk now supports a new range of Android Cross Compilers. Are you planning to support them?
3. As the Target of the Project is set up through the Wizard, is there any way to change that? Like switching from arm to x86?
Title: Re: Android Module Wizard
Post by: sohag on January 12, 2019, 06:49:05 am
How to place checkbox on jsRecyclerView
Title: Re: Android Module Wizard
Post by: jmpessoa on February 08, 2019, 09:32:38 am
Quote
How to place checkbox on jsRecyclerView...

Done!

Added support to "Check", "Rating" and "Switch" widgets...

NEW demo: "AppCompatRecyclerViewDemo1"

Thank you!
Title: Re: Android Module Wizard
Post by: nullpointer on February 20, 2019, 02:14:15 am
what do i miss? why can't I display AndroidModule2 using this code?  %)

if(AndroidModule2 = nil) then
  begin
      gApp.CreateForm(TAndroidModule2, AndroidModule2);
      AndroidModule2.Init(gApp);
  end
  else
  begin
    AndroidModule2.Show;
  end;

Title: Re: Android Module Wizard
Post by: jmpessoa on February 20, 2019, 05:10:16 am

Quote
what do i miss? why can't I display AndroidModule2 using this code?

Please,  put your project in some "online-drive". I will try help.....
Title: Re: Android Module Wizard
Post by: nullpointer on February 20, 2019, 06:23:48 am

Quote
what do i miss? why can't I display AndroidModule2 using this code?

Please,  put your project in some "online-drive". I will try help.....

I solved this problem by changing the background color of AndroidModule2. So it turns out that actually AndroidModule2 has been displayed only because the background color is the same as AndroidModule1 so it's not visible. :D
Title: Re: Android Module Wizard
Post by: nullpointer on March 01, 2019, 02:20:06 am
I did not find an example of a login page in the LAMW demo folder. However, I want to remove Titlebar but I don't find it in the AndroidModule Object Inspector.
Title: Re: Android Module Wizard
Post by: jmpessoa on March 01, 2019, 03:23:57 am
Quote
I did not find an example of a login page in the LAMW demo folder....

Login, where?? [http] web server? Or just "page layout"?

Quote
I want to remove Titlebar...

Go to your project folder ".....\res\values-v21\styles.xml"

change this line:

<style name="AppBaseTheme" parent="android:Theme.DeviceDefault">

to:

<style name="AppBaseTheme" parent="android:Theme.Holo.Light.NoActionBar">

But you can notice some more [unexpected] changes ...


EDITED: Fixed "Project Options" --> "LAMW..." --> "Application" theme

Please,  update LAMW from github...

Thank you!
Title: Re: Android Module Wizard
Post by: nullpointer on March 02, 2019, 08:00:17 am
Quote

EDITED: Fixed "Project Options" --> "LAMW..." --> "Application" theme

Please,  update LAMW from github...

Thank you!

Nice! Thank you jmpessoa 
Title: Re: Android Module Wizard
Post by: jmpessoa on August 13, 2019, 10:52:28 pm
Hi, All


LAMW, major update!
       
Version 0.8 - rev 05 - 13 - August - 2019
   
   NEW! jForm/jPanel/jImageView [effect]  Animation Trasition!!!
      Add properties:
         Animation {Fade, RightToLeft, LeftToRight)
         AnimationDuration

         how it works:
            jForm {InitShowing, Show, Close}
            jPanel/jImageView {BringToFront}
      
   NEW!  demo "AppAnimationDemo1"  -> jForm/jPanel/jImageView  Animation       
   MEW!  demo  "AppImageViewListDemo1"   --> jImageView  Animation
   UPDATED! demo "AppCompatNavigationDrawerDemo1" -> jPanel   Animation


        NEW! Compoments!
      jSoundPool componet and "AppSoundPoolDemo"   [thanks to @TR3E!]
      jMidiManager componet and "AppMidiManagerDemo1" [thanks to Marco Bramardi]
      jWifiManager componet and "AppWifiManagerDemo1"

      jExpression componet and "AppExpressionDemo1"     [link to a local "jar" file...]
      jZBarcodeScannerView componet and "AppZBarcodeScannerViewDemo1"

      jsContinuousScrollableImageView component and "AppCompatContinuousScrollableImageViewDemo1"

   NEW! Palette "JCenter" <-- Link to external java libraries,  need "Gradle"

      jcSignaturePad componet and "AppJCenterSignaturePadDemo1"
      jcOpenStreetMap componet and "AppJCenterOpenStreetMapDemo2"
      jcMikrotikRouterOS componet and "AppJCenterMikrotikRouterOSDemo1"
      jcLantern componet and "AppJCenterLanternDemo1"
      jcScreenShot componet and "AppJCenterScreenShotDemo1"


   CHANGED!
      ref. https://forum.lazarus.freepascal.org/index.php/topic,46340.0.html

      "Init"  no longer show the form....Some old code can be easily fixed:

      example:

      procedure TAndroidModule1.jButton1Click(Sender: TObject);
      begin
           if AndroidModule2 = nil then
           begin
                gApp.CreateForm(TAndroidModule2, AndroidModule2);
                AndroidModule2.InitShowing(gApp);                             // <-- Fixed!!!
           end
           else
           begin
                AndroidModule2.Show();
           end;
      end;


   REQUIREMENTS:

      1. Java JDK 1.8 
      2. Gradle 4.4.1 [or up] + Internet Connection!
      3. Android SDK "plataforms" 28 + "build-tools" 28.0.3   [Min "target" need by Google Play Store]
      4. Android SDK/Extra  "Support Repository"
      5. Android SDK/Extra  "Support Library"
      6. Android SDK/Extra  "Google Repository"
      7. Android SDK/Extra  "Google Play Services"
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 05:16:08 am
Btw, I have one question. Hehe...  :D

Is that possible to show SDK Windows automatically when this happening? (in attachment)
Because the error show require to accept the license, but there's no license agreement window is there.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 06:35:32 am
No. That is a gradle [process] report....

What this "error" does mean?   [Gradle, won't be able to install it, because it depends on "accept license"  event...]

So, you need [manually] install the required sdk/platform "android-28"  [and sdk/built-tools"28.0.3"].

Just execute the GUI "SDK Manager" (aka "sdk/tool/android.bat")
[and there you wil need  "accept license" to update your system]


 
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 06:38:47 am

No. That is a gradle [process] report....

What this "error" does mean?   [Gradle, won't be able to install it, because it depends on "accept license"  event...]

So, you need [manually] install the required sdk/platform "android-28"  [and sdk/built-tools"28.0.3"].

Just execute the GUI "SDK Manager" (aka "sdk/tool/android.bat")
Noted.

I just updated LAMW, there are many things are changed. Like forcing SDK 28 and all my App Test doesn't work anymore, it's always stopped working. I think I should revert to previous LAMW.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 06:42:41 am

Quote
  I think I should revert to previous LAMW....

No! You need only update your sdk!!!
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 06:49:30 am

Quote
  I think I should revert to previous LAMW....

No! You need only update your sdk!!!
I do it already, but all of my projects still stopped working. I even modifying old build.gradle file, because it won't build anymore.

I think, there are major causes: I try to add easel's panel into the main form after the splash screen, and I think I can't init any form in the JNI_Promt event anymore.\

I'm using AppCompatNoActionbar, btw.

Code: Pascal  [Select][+][-]
  1. procedure TViewSplash.tmrStartupTimer(Sender: TObject);
  2. begin
  3.   if clStartup < 11 then
  4.   begin
  5.      clStartup += 1;
  6.      pbStartup.Max := 10;
  7.      pbStartup.Progress := clStartup;
  8.   end
  9.   else
  10.   begin
  11.     clStartup := 0;
  12.     tmrStartup.Enabled := False;
  13.     gApp.CreateForm(TMainControl, MainControl);
  14.     MainControl.InitShowing(gApp);
  15.   end;
  16. end;
  17.  

This is problematic.
Code: Pascal  [Select][+][-]
  1. procedure TMainControl.MainControlJNIPrompt(Sender: TObject);
  2. begin
  3.   if not Assigned(ViewLogin) then
  4.   begin
  5.     gApp.CreateForm(TViewLogin, ViewLogin);
  6.     ViewLogin.Init(gApp);
  7.     ViewLogin.pnView.SetViewParent(pnView);
  8.   end;
  9. end;  
  10.  

Code: Pascal  [Select][+][-]
  1. procedure TViewLogin.ViewLoginJNIPrompt(Sender: TObject);
  2. begin
  3.   jsFloatingButton1.SetPressedRippleColor(colbrCyan);
  4.   jsFloatingButton1.ImageIdentifier:= 'ic_gear_white_36dp';
  5.   edUsername.Text := '';
  6.   edPassword.Text := '';
  7. end;
  8.  
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 07:03:55 am

The "AppCompatNavigationDrawerDemo1"  is up-to-date!!!

The main change is documented!

Code: Pascal  [Select][+][-]
  1.       procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2.       begin
  3.            if AndroidModule2 = nil then
  4.            begin
  5.                 gApp.CreateForm(TAndroidModule2, AndroidModule2);
  6.                 AndroidModule2.InitShowing(gApp);                             // <-- Fixed!!!
  7.            end  
  8.            else
  9.            begin
  10.                 AndroidModule2.Show();
  11.            end;
  12.       end;
  13.  
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 07:20:41 am
I think that's doesn't what I mean. But, yeah. The demo doesn't even work too.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 07:22:27 am

You code:
Quote
ViewLogin.Init(gApp);     

What about:  ViewLogin.InitShowing(gApp); ??
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 07:32:06 am

You code:
Quote
ViewLogin.Init(gApp);     

What about:  ViewLogin.InitShowing(gApp); ??
I mean, it's actEasel...  :D

Code: Pascal  [Select][+][-]
  1. if not Assigned(ViewLogin) then
  2.   begin
  3.     gApp.CreateForm(TViewLogin, ViewLogin);
  4.     ViewLogin.Init(gApp); // <- Don't show actEasel forms...
  5.     ViewLogin.pnView.SetViewParent(pnView); // <- here you are.
  6.   end;
  7.  

Btw, actEasel on "AppCompatNavigationDrawerDemo1" have the same problem too.  :(
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 07:37:31 am

hummmm... and do you need:

Code: Pascal  [Select][+][-]
  1. procedure TViewLogin.ViewLoginJNIPrompt(Sender: TObject);
  2. begin
  3.   jsFloatingButton1.SetPressedRippleColor(colbrCyan);
  4.   jsFloatingButton1.ImageIdentifier:= 'ic_gear_white_36dp';
  5.   edUsername.Text := '';
  6.   edPassword.Text := '';
  7. end;
  8.  

after  "ViewLogin.Init(gApp)" ???
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 07:50:33 am

hummmm... and do you need:

after  "ViewLogin.Init(gApp)" ???
No, it's just a sample what I'm doing in TViewLogin's JNI_Prompt. Because of that design time problem, I am tired to clear edUsername.Text every time I open project so I add that into JNI_Promt. After removing them it's still same, I can't init TViewLogin or any actEasel forms.
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 07:55:37 am
Btw, I revert into LAMW from 02 August 2019, and actEasel... It works again.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 08:05:15 am
Quote
if not Assigned(ViewLogin) then
  begin
    gApp.CreateForm(TViewLogin, ViewLogin);
    ViewLogin.Init(gApp); // <- Don't show actEasel forms...
    ViewLogin.pnView.SetViewParent(pnView); // <- here you are.
  end;

From demo, there are some more code

Code: Pascal  [Select][+][-]
  1.     if AndroidModule2 = nil then
  2.     begin
  3.        gApp.CreateForm(TAndroidModule2, AndroidModule2); //hint: property "ActiveMode = actEasel" dont "show"  form
  4.        AndroidModule2.Init(gApp);   //fire OnJNIPrompt ...
  5.        AndroidModule2.jPanel1.Parent:= Self.jPanel2;   // <<-need to handle LayoutParamWidth/LayoutParamHeight rotate      
  6.        AndroidModule2.jPanel1.SetViewParent(Self.jPanel2.View); //add scene 2  to Self.jPanel2
  7.     end;
  8.     ............................
  9.     AndroidModule2.jPanel1.BringToFront();     // << --- What about??
  10.  

Quote
    AndroidModule2.jPanel1.BringToFront();     // << --- What about??

Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 08:11:02 am
Quote
    AndroidModule2.jPanel1.BringToFront();     // << --- What about??
It's same, it will start crash on this line "AndroidModule2.Init(gApp)".
Title: Re: Android Module Wizard
Post by: jmpessoa on August 22, 2019, 08:22:00 am
 :-[
 
I found a bug!   [life time: a day ago....]

Please,  update "jEditText.java" template from the git!

[folder "................\android_wizard\smartdesigner\java"]

Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 08:25:31 am
Thank you...  ;)

I will test it at night, I'll report it later.
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 22, 2019, 11:16:54 am
I just tested. Seems the actEasel in the "AppCompatNavigationDrawerDemo1" still doesn't work. I don't know why.
Any clues?  :o


Video: https://youtu.be/row4yF2qUf4
My Phone: Sony Xperia X Performance, SOV33; Android 8.0.0.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 23, 2019, 02:17:10 am

Sorry...

Here,  I can run "AppCompatNavigationDrawerDemo1" [and "AppAnimationDemo1"]  on
all my  real  devices..... Android 4.3, Android 5.0.1 and  Android 6.0.1

Maybe, you need some "Run" --> "Clean up and  Build" or even a clean  packages re-install....
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 24, 2019, 05:24:09 am
I fixed it.

android_bridges/Laz_And_Controls.pas, Line: 11830 in jPanel.Init(refApp: jApp);

Code: Pascal  [Select][+][-]
  1. if not FInitialized then
  2.   begin
  3.    if jForm(Self.Owner).ActivityMode <> actEasel then
  4.    begin
  5.      if FAnimationMode <> animNone then //default
  6.        jPanel_SetAnimationMode(FjEnv, FjObject, Ord(FAnimationMode));
  7.  
  8.      if FAnimationDurationIn <> 1500 then //default
  9.        jPanel_SetAnimationDurationIn(FjEnv, FjObject, FAnimationDurationIn);
  10.      // Do not run animation mode in actEasel!!
  11.      // It causing an apocalyptic crash in Android 8.0.0 (tested on Xperia SOV33)
  12.    end;  
  13.  
Title: Re: Android Module Wizard
Post by: jmpessoa on August 24, 2019, 06:47:36 am

Nice!

Quote
Do not use animation mode in actEasel....

So,  the jPanel animation on "BringToFront" will be lost?
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 24, 2019, 06:56:06 am
So,  the jPanel animation on "BringToFront" will be lost?
I think so. I don't know what is wrong with that in the Android 8.0.0, maybe we should disable that for now until we know what the problem, I'm not pretty sure if it caused by Java template (maybe?), because I don't understand Java when I tried to inspect the codes.  :D
Title: Re: Android Module Wizard
Post by: jmpessoa on August 24, 2019, 07:13:31 am
Quote
I don't know what is wrong with that in the Android 8.0.0...

Ok. I will do some test on Android 8.0.0 !!!

Thank you!
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 24, 2019, 07:43:23 am
(edit)
Sorry... There's something wrong with my LAMW installation.  :-[
Now, I can't compile my project after deleting my old LAMW installation. I'll try to reinstall Lazarus.
It's maybe the culprit of why LAMW copying the wrong Java template, even after I've installed newer LAMW. It's caused by different path of an old and new installation.

It's says Fatal: [EFOpenError] Failed: Unable to open file "my_old_path\android_wizard\smartdesigner\java\Controls.java"
Title: Re: Android Module Wizard
Post by: jmpessoa on August 24, 2019, 08:06:29 am

Quote
I think there's something is wrong....

Yes!  your jPanel.java  is outdated!!!!!

This means that you have only partially updated to the "LAMW 0.8.5" !!!

You can do a  "diff" from the "jPanel.java" on git:

https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/android_wizard/smartdesigner/java/jPanel.java
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on August 24, 2019, 08:10:05 am

Quote
I think there's something is wrong....

Yes!  your jPanel.java  is outdated!!!!!

I just found the LAMW.ini in the Lazarus config folder. That's why it trying to copying my old LAMW.
I think that "flag:=false" in TLamwGlobalSettings.ReloadIni is okay to removed, since I have multiple LAMW.
Title: Re: Android Module Wizard
Post by: jmpessoa on August 24, 2019, 08:14:31 am

It's part of our programming adventure.... let's move on!

Thank you!
Title: Re: Android Module Wizard
Post by: AFFRIZA 亜風実 on September 02, 2019, 10:30:59 am
Hello, Marquez. Can you inspect on unit LamwDesigner on line 1812?

So, I have 2 forms, the first is actSplash (with name ControlSplash), and the second is actMain (with name ControlMain).
If I modified properties in actMain, it forcing an update on ProjectStartModule into ControlMain. So, it makes me to always modify the LPI file.

I have an idea here. How about make actSplash is prioritized than actMain. Like this:

Code: Pascal  [Select][+][-]
  1.     if (Instance = AndroidForm)
  2.     and (AndroidForm.ActivityMode in [actMain, actSplash])
  3.     and FProjFile.IsPartOfProject then
  4.     begin
  5.       if AndroidForm.ActivityMode = actSplash then
  6.         LamwSmartDesigner.UpdateProjectStartModule(AndroidForm.Name)
  7.       else
  8.         LamwSmartDesigner.UpdateProjectStartModule(AndroidForm.Name);
  9.     end;          
  10.  

Thank you.  :D
Title: Re: Android Module Wizard
Post by: kordal on September 28, 2019, 01:54:59 am
Hi everyone) Android Module Wizard is a good job. Although I do not like Pascal, it is probably a better Android app development tool than Delphi. The most important feature is the size of the application, with the same code it can vary 25 times. It is very important. Thank you very much!

So. I added some functionality to the jBitmap, jCanvas, and jDrawingView component classes. Now in order:
1. jBitmap. Added function:
Code: Pascal  [Select][+][-]
  1. LoadFromBuffer (buffer: pointer; size: integer);
2. jCanvas and jDrawingView. Added overloaded functions:
Code: Pascal  [Select][+][-]
  1. procedure DrawBitmap(bitMap: jObject; srcLeft, srcTop, srcRight, srcBottom, dstLeft, dstTop, dstRight, dstBottom: Integer);
  2. procedure DrawFrame(bitMap: jObject; srcX, srcY, srcW, srcH, X, Y, W, H: Integer; rotateDegree: Single=0);
  3. procedure DrawFrame(bitMap: jObject; X, Y, Index, Size: Integer; scaleFactor: Single=1; rotateDegree: Single=0);

I attach the modified files, as well as a new demo using them. In addition, two utilities are included:
1. bin2pas - a packer of binary files in * .pas
2. JC Sign - a program for convenient viewing of signatures of * .class java files.

lamw_modif.7z (http://unimods.club/lamw_modif.7z)

Have fun :)
Title: Re: Android Module Wizard
Post by: jmpessoa on September 28, 2019, 11:54:58 pm

@kordal:
Quote
I added some functionality to the jBitmap, jCanvas, and jDrawingView component classes....

Commited!!

Thank you!
Title: Re: Android Module Wizard
Post by: kordal on October 04, 2019, 06:17:36 pm
1. Added a new type in the AndroidWidget unit:
Code: Pascal  [Select][+][-]
  1. type
  2. // ...
  3.   PColor = ^TColor;
  4.   TColor = -$7FFFFFFF-1..$7FFFFFFF;

2. I modified and fixed some functions in the jDrawingView component. So:
jDrawingView.pas
Code: Pascal  [Select][+][-]
  1. interface
  2.  
  3. jDrawingView = class(jVisualControl)
  4. public
  5. // ...
  6.   procedure SetPaintColor( _color: TColor); overload;
  7.   procedure DrawRoundRect(Left, Top, Right, Bottom, radiusX, radiusY: Single);
  8. // ..
  9. end;
  10.  
  11. procedure jDrawingView_DrawRoundRect(env: PJNIEnv; _jdrawingview: JObject; _left, _top, _right, _bottom, _rx, _ry: Single);
  12.  
  13. implementation
  14.  
  15. procedure jDrawingView.SetPaintColor(_color: TColor);
  16. begin
  17.   if FInitialized then
  18.      jDrawingView_SetPaintColor(FjEnv, FjObject, _color);
  19. end;
  20.  
  21. procedure jDrawingView.DrawRoundRect(Left, Top, Right, Bottom, radiusX, radiusY: Single);
  22. begin
  23.   if FInitialized then
  24.      jDrawingView_DrawRoundRect(FjEnv, FjObject, Left, Top, Right, Bottom, radiusX, radiusY);
  25. end;
  26.  
  27. // ...
  28. procedure jDrawingView_DrawRoundRect(env: PJNIEnv; _jdrawingview: JObject; _left, _top, _right, _bottom, _rx, _ry: Single);
  29. var
  30.   jParams: array[0..5] of jValue;
  31.   jMethod: jMethodID = nil;
  32.   jCls   : jClass = nil;
  33. begin
  34.   jParams[0].f:= _left;
  35.   jParams[1].f:= _top;
  36.   jParams[2].f:= _right;
  37.   jParams[3].f:= _bottom;
  38.   jParams[4].f:= _rx;
  39.   jParams[5].f:= _ry;
  40.   jCls:= env^.GetObjectClass(env, _jdrawingview);
  41.   jMethod:= env^.GetMethodID(env, jCls, 'DrawRoundRect', '(FFFFFF)V');
  42.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  43.   env^.DeleteLocalRef(env, jCls);
  44. end;    
  45.  
jDrawingView.java
Code: Java  [Select][+][-]
  1. public void DrawRoundRect(float _left, float _top, float _right, float _bottom, float _rx, float _ry) {
  2.         mCanvas.drawRoundRect(_left, _top, _right, _bottom, _rx, _ry, mDrawPaint);
  3. }
Code: Pascal  [Select][+][-]
  1. // example
  2. procedure jDrawingView_DrawText(env: PJNIEnv; _jdrawingview: JObject; _text: string; _x: single; _y: single);
  3. var
  4.   jParams: array[0..2] of jValue;
  5.   jMethod: jMethodID=nil;
  6.   jCls: jClass=nil;
  7. begin
  8.   // ...
  9.   // example calls
  10.   //    ...DrawText('String', 10, 10); its ok
  11.   //    ...DrawText('Строка', 10, 10); filed !
  12.  
  13.   // modified line:
  14.   // jParams[0].l:= env^.NewStringUTF(env, PChar(_text));  // bug!!!
  15.   jParams[0].l:= env^.NewString(env, PjChar(UTF8Decode(_text)), Length(_text)); // fix !!
  16.   jParams[1].f:= _x;
  17.   jParams[2].f:= _y;
  18.   // ...
  19.   env^.DeleteLocalRef(env, jCls);
  20. end;
  21.  
Title: Re: Android Module Wizard
Post by: jmpessoa on October 04, 2019, 10:46:50 pm

Quote
There was a problem while displaying Cyrillic in DrawText functions......

Code: Pascal  [Select][+][-]
  1.  // jParams[0].l:= env^.NewStringUTF(env, PChar(_text));  // bug!!!
  2.  jParams[0].l:= env^.NewString(env, PjChar(UTF8Decode(_text)), Length(_text)); // fix !!
  3.  

So this could be happening all over LAMW?



Title: Re: Android Module Wizard
Post by: kordal on October 04, 2019, 11:33:50 pm
In theory. It is necessary to check while I noticed an error only in the jDrawingView module in DrawText functions. It is likely that all those modules that use the same approach for text output will fail.

Just in case, version FPC 3.2.0, Lazarus 2.0.2, Aarch64 chipset, jdk1.8.0_221, SDK 29, APK Builder - Ant. All tests were conducted on a real Android devices.

upd.
Code: Pascal  [Select][+][-]
  1. jParams [0] .l: = env ^ .NewStringUTF (env, PChar (_text));
After several rebuilding of the project and LAMW, it worked. Need more tests. The problem arose precisely with the Cyrillic text.
Title: Re: Android Module Wizard
Post by: jmpessoa on October 05, 2019, 04:23:23 am

Suggestions/improvements commiteds!!!

Thank you!
Title: Re: Android Module Wizard
Post by: kordal on October 08, 2019, 02:10:06 am
1. I converted the drawing functions to the Float version, because everywhere they use Float coordinates instead of Integer. Therefore, it will be more correct.
DrawingView.pas
Code: Pascal  [Select][+][-]
  1.  // ...
  2. public  
  3.   procedure DrawBitmap(bitMap: jObject; srcLeft, srcTop, srcRight, srcBottom: Integer; dstLeft, dstTop, dstRight, dstBottom: Single); overload;
  4.   procedure DrawFrame(bitMap: jObject; srcX, srcY, srcW, srcH: Integer; X, Y, W, H: Single; rotateDegree: Single=0); overload; // by Kordal
  5.   procedure DrawFrame(bitMap: jObject; X, Y: Single; Index, Size: Integer; scaleFactor: Single=1; rotateDegree: Single=0); overload;
  6. end;
  7. //...
  8.   procedure jDrawingView_DrawBitmap(env: PJNIEnv; _jdrawingview: JObject; _bitmap: jObject; _sl, _st, _sr, _sb: Integer; _dl, _dt, _dr, _db: Single); overload;
  9.   procedure jDrawingView_DrawFrame(env: PJNIEnv; _jdrawingview: JObject; _bitmap: jObject; _srcX, _srcY, _srcW, _srcH: Integer; _X, _Y, _Wh, _Ht, _rotateDegree: Single); overload;
  10.   procedure jDrawingView_DrawFrame(env: PJNIEnv; _jdrawingview: JObject; _bitmap: jObject; _X, _Y: Single; _Index, _Size: Integer; _scaleFactor, _rotateDegree: Single); overload;
  11.  
  12. implementation
  13.  
  14. procedure jDrawingView.DrawBitmap(bitMap: jObject; srcLeft, srcTop, srcRight, srcBottom: Integer; dstLeft, dstTop, dstRight, dstBottom: Single);
  15. begin
  16.   if FInitialized then
  17.     jDrawingView_DrawBitmap(FjEnv, FjObject, bitMap, srcLeft, srcTop, srcRight, srcBottom, dstLeft, dstTop, dstRight, dstBottom);
  18. end;
  19.  
  20. procedure jDrawingView.DrawFrame(bitMap: jObject; srcX, srcY, srcW, srcH: Integer; X, Y, W, H, rotateDegree: Single);
  21. begin
  22.   if FInitialized then
  23.     jDrawingView_DrawFrame(FjEnv, FjObject, bitMap, srcX, srcY, srcW, srcH, X, Y, W, H, rotateDegree);
  24. end;
  25.  
  26. procedure jDrawingView.DrawFrame(bitMap: jObject; X, Y: Single; Index, Size: Integer; scaleFactor: Single; rotateDegree: Single);
  27. begin
  28.   if FInitialized then
  29.     jDrawingView_DrawFrame(FjEnv, FjObject, bitMap, X, Y, Index, Size, scaleFactor, rotateDegree);
  30. end;
  31.  
  32. procedure jDrawingView_DrawBitmap(env: PJNIEnv; _jdrawingview: JObject; _bitmap: jObject; _sl, _st, _sr, _sb: Integer; _dl, _dt, _dr, _db: Single);
  33. var
  34.   jParams: array [0..8] of jValue;
  35.   jMethod: jMethodID=nil;
  36.   jCls   : jClass=nil;
  37. begin
  38.   jParams[0].l := _bitmap;
  39.   jParams[1].i := _sl;
  40.   jParams[2].i := _st;
  41.   jParams[3].i := _sr;
  42.   jParams[4].i := _sb;
  43.   jParams[5].f := _dl;
  44.   jParams[6].f := _dt;
  45.   jParams[7].f := _dr;
  46.   jParams[8].f := _db;
  47.   jCls:= env^.GetObjectClass(env, _jdrawingview);
  48.   jMethod:= env^.GetMethodID(env, jCls, 'DrawBitmap', '(Landroid/graphics/Bitmap;IIIIFFFF)V');
  49.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  50.   env^.DeleteLocalRef(env,  jCls);
  51. end;        
  52.  
  53. procedure jDrawingView_DrawFrame(env: PJNIEnv; _jdrawingview: JObject; _bitmap: jObject; _srcX, _srcY, _srcW, _srcH: Integer; _X, _Y, _Wh, _Ht, _rotateDegree: Single);
  54. var
  55.   jParams: array [0..9] of jValue;
  56.   jMethod: jMethodID = nil;
  57.   jCls   : jClass = nil;
  58. begin
  59.   jParams[0].l := _bitmap;
  60.   jParams[1].i := _srcX;
  61.   jParams[2].i := _srcY;
  62.   jParams[3].i := _srcW;
  63.   jParams[4].i := _srcH;
  64.   jParams[5].f := _X;
  65.   jParams[6].f := _Y;
  66.   jParams[7].f := _Wh;
  67.   jParams[8].f := _Ht;
  68.   jParams[9].f := _rotateDegree;
  69.   jCls := env^.GetObjectClass(env, _jdrawingview);
  70.   jMethod := env^.GetMethodID(env, jCls, 'DrawFrame', '(Landroid/graphics/Bitmap;IIIIFFFFF)V');
  71.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  72.   env^.DeleteLocalRef(env, jCls);
  73. end;
  74.  
  75. procedure jDrawingView_DrawFrame(env: PJNIEnv; _jdrawingview: JObject; _bitmap: jObject; _X, _Y: Single; _Index, _Size: Integer; _scaleFactor, _rotateDegree: Single);
  76. var
  77.   jParams: array [0..6] of jValue;
  78.   jMethod: jMethodID = nil;
  79.   jCls   : jClass = nil;
  80. begin
  81.   jParams[0].l := _bitmap;
  82.   jParams[1].f := _X;
  83.   jParams[2].f := _Y;
  84.   jParams[3].i := _Index;
  85.   jParams[4].i := _Size;
  86.   jParams[5].f := _scaleFactor;
  87.   jParams[6].f := _rotateDegree;
  88.   jCls := env^.GetObjectClass(env, _jdrawingview);
  89.   jMethod := env^.GetMethodID(env, jCls, 'DrawFrame', '(Landroid/graphics/Bitmap;FFIIFF)V');
  90.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  91.   env^.DeleteLocalRef(env, jCls);
  92. end;                                    
  93.  

jDrawingView.java
Code: Java  [Select][+][-]
  1. // by Kordal
  2.         public void DrawBitmap(Bitmap _bitMap, int _srcLeft, int _srcTop, int _srcRight, int _srcBottom, float _dstLeft, float _dstTop, float _dstRight, float _dstBottom) {
  3.                 Rect srcRect = new Rect(_srcLeft, _srcTop, _srcRight, _srcBottom);
  4.         RectF dstRect = new RectF(_dstLeft, _dstTop, _dstRight, _dstBottom);
  5.                
  6.                 mCanvas.drawBitmap(_bitMap, srcRect, dstRect, mDrawPaint);
  7.         }
  8.        
  9.         public void DrawFrame(Bitmap _bitMap, int _srcX, int _srcY, int _srcW, int _srcH, float _X, float _Y, float _Wh, float _Ht, float _rotateDegree) {
  10.                 Rect srcRect = new Rect(_srcX, _srcY, _srcX + _srcW, _srcY + _srcH);
  11.         RectF dstRect = new RectF(_X, _Y, _X + _Wh, _Y + _Ht);
  12.                
  13.                 if (_rotateDegree != 0) {
  14.                         mCanvas.save();
  15.                         mCanvas.rotate(_rotateDegree, _X + _Wh / 2, _Y + _Ht / 2);
  16.                         mCanvas.drawBitmap(_bitMap, srcRect, dstRect, mDrawPaint);
  17.                         mCanvas.restore();
  18.                 } else {
  19.                         mCanvas.drawBitmap(_bitMap, srcRect, dstRect, mDrawPaint);
  20.                 }
  21.         }
  22.        
  23.         public void DrawFrame(Bitmap _bitMap, float _X, float _Y, int _Index, int _Size, float _scaleFactor, float _rotateDegree) {
  24.                 float sf = _Size * _scaleFactor;
  25.                 DrawFrame(_bitMap, _Index % (_bitMap.getWidth() / _Size) * _Size, _Index / (_bitMap.getWidth() / _Size) * _Size, _Size, _Size, _X, _Y, sf, sf, _rotateDegree);
  26.         }      
  27.  

2. Functions added:
DrawingView.pas
Code: Pascal  [Select][+][-]
  1. // ...
  2. public
  3.   procedure DrawGrid(Left, Top, Width, Height: Single; cellsX, cellsY: Integer);  
  4.   procedure ClipRect(Left, Top, Right, Bottom: Single);  
  5.   function GetDensity(): Single;
  6.  
  7. published
  8.   property Density: Single read GetDensity;
  9. // ...
  10. end;
  11.  
  12. procedure jDrawingView_DrawGrid(env: PJNIEnv; _jdrawingview: JObject; _left, _top, _width, _height: Single; _cellsX, _cellsY: Integer);
  13. procedure jDrawingView_ClipRect(env: PJNIEnv; _jdrawingview: JObject; Left, Top, Right, Bottom: Single);
  14. function  jDrawingView_GetDensity(env: PJNIEnv; _jdrawingview: JObject): Single;
  15.  
  16. implementation
  17.  
  18. function jDrawingView.GetDensity(): Single;
  19. begin
  20.   Result := 1;
  21.   if not FInitialized then Exit;
  22.   Result := jDrawingView_GetDensity(FjEnv, FjObject);
  23. end;
  24.  
  25. procedure jDrawingView.ClipRect(Left, Top, Right, Bottom: Single);
  26. begin
  27.   if FInitialized then
  28.     jDrawingView_ClipRect(FjEnv, FjObject, Left, Top, Right, Bottom);
  29. end;  
  30.  
  31. procedure jDrawingView.DrawGrid(Left, Top, Width, Height: Single; cellsX, cellsY: Integer);
  32. begin
  33.   if FInitialized then
  34.     jDrawingView_DrawGrid(FjEnv, FjObject, Left, Top, Width, Height, cellsX, cellsY);
  35. end;  
  36.  
  37. procedure jDrawingView_DrawGrid(env: PJNIEnv; _jdrawingview: JObject; _left, _top, _width, _height: Single; _cellsX, _cellsY: Integer);
  38. var
  39.   jParams: array[0..5] of jValue;
  40.   jMethod: jMethodID = nil;
  41.   jCls   : jClass = nil;
  42. begin
  43.   jParams[0].f:= _left;
  44.   jParams[1].f:= _top;
  45.   jParams[2].f:= _width;
  46.   jParams[3].f:= _height;
  47.   jParams[4].i:= _cellsX;
  48.   jParams[5].i:= _cellsY;
  49.   jCls:= env^.GetObjectClass(env, _jdrawingview);
  50.   jMethod:= env^.GetMethodID(env, jCls, 'DrawGrid', '(FFFFII)V');
  51.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  52.   env^.DeleteLocalRef(env, jCls);
  53. end;      
  54.  
  55. function jDrawingView_GetDensity(env: PJNIEnv; _jdrawingview: JObject): Single;
  56. var
  57.   jMethod: jMethodID=nil;
  58.   jCls: jClass=nil;
  59. begin
  60.   jCls:= env^.GetObjectClass(env, _jdrawingview);
  61.   jMethod:= env^.GetMethodID(env, jCls, 'GetDensity', '()F');
  62.   Result:= env^.CallFloatMethod(env, _jdrawingview, jMethod);
  63.   env^.DeleteLocalRef(env, jCls);
  64. end;
  65.  
  66. procedure jDrawingView_ClipRect(env: PJNIEnv; _jdrawingview: JObject; Left, Top, Right, Bottom: Single);
  67. var
  68.   jParams: array[0..3] of jValue;
  69.   jMethod: jMethodID = nil;
  70.   jCls   : jClass = nil;
  71. begin
  72.   jParams[0].f:= Left;
  73.   jParams[0].f:= Top;
  74.   jParams[0].f:= Right;
  75.   jParams[0].f:= Bottom;
  76.   jCls:= env^.GetObjectClass(env, _jdrawingview);
  77.   jMethod:= env^.GetMethodID(env, jCls, 'ClipRect', '(FFFF)V');
  78.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  79.   env^.DeleteLocalRef(env, jCls);
  80. end;          
  81.  

jDrawingView.java
Code: Java  [Select][+][-]
  1. public float GetDensity() {
  2.                 return controls.activity.getResources().getDisplayMetrics().density;
  3.         }      
  4.  
  5. public void ClipRect(float _left, float _top, float _right, float _bottom) {
  6.         mCanvas.clipRect(_left, _top, _right, _bottom);
  7.     }
  8.  
  9. public void DrawGrid(float _left, float _top, float _width, float _height, int _cellsX, int _cellsY) {
  10.                 float cw = _width / _cellsX;
  11.                 float ch = _height / _cellsY;
  12.                 for (int i = 0; i < _cellsX + 1; i++) {
  13.                         mCanvas.drawLine(_left + i * cw, _top, _left + i * cw, _top + _height, mDrawPaint); // draw Y lines
  14.                 }
  15.                 for (int i = 0; i < _cellsY + 1; i++) {
  16.                         mCanvas.drawLine(_left, _top + i * ch, _left + _width, _top + i * ch, mDrawPaint); // draw X lines
  17.                 }
  18.         }      
  19.  

3. Some modifications and the final version of the text output. The string is passed as an array of bytes, and on the java side we can do any conversion. (as I noticed, Delphi does not use NewStringUTF function either). Interesting article: https://juejin.im/post/5a96a79e6fb9a0635865ace3  :)
jDrawingView.java
Code: Java  [Select][+][-]
  1. import java.nio.charset.Charset;
  2. //...
  3. public class jDrawingView extends View /*dummy*/ {
  4.   //...
  5.   private final Charset UTF8_CHARSET = Charset.forName("UTF-8");
  6.   // ...
  7.  
  8.   // in drawing functions where the rotation, translation or scale matrix is ​​not used, the following function calls are not needed:
  9.   // mCanvas.save () ;
  10.   // mCanvas.restore ();
  11.   // example:
  12.   public void DrawBitmap(Bitmap _bitmap, int _width, int _height) {
  13.         Bitmap bmp = GetResizedBitmap(_bitmap, _width, _height);
  14.         Rect rect = new Rect(0, 0, _width, _height);
  15.         // mCanvas.save(); // not needed!
  16.         mCanvas.drawBitmap(bmp, null, rect, mDrawPaint);
  17.         // mCanvas.restore(); // not needed!
  18.     }
  19.        
  20.     public void DrawBitmap(Bitmap _bitmap, float _x, float _y, float _angleDegree) {
  21.         int x = (int) _x;
  22.         int y = (int) _y;
  23.         Bitmap bmp = GetResizedBitmap(_bitmap, _bitmap.getWidth(), _bitmap.getHeight());
  24.         mCanvas.save(); // needed, uses rotate matrix
  25.         mCanvas.rotate(_angleDegree, x + _bitmap.getWidth() / 2, y + _bitmap.getHeight() / 2);
  26.         mCanvas.drawBitmap(bmp, x, y, null);
  27.         mCanvas.restore();
  28.     }
  29.  
  30.    // new
  31.    private String decodeUTF8(byte[] bytes) {
  32.    return new String(bytes, UTF8_CHARSET);
  33.    //return new String(bytes);
  34.   }
  35.  
  36.   public void DrawText(byte[] _text, float _x, float _y) {
  37.                 mCanvas.drawText(decodeUTF8(_text), _x, _y, mTextPaint);
  38.     }
  39.  

DrawingView.pas
Code: Pascal  [Select][+][-]
  1. procedure jDrawingView_DrawText(env: PJNIEnv; _jdrawingview: JObject; _text: string; _x: single; _y: single);
  2. var
  3.   jParams: array[0..2] of jValue;
  4.   jMethod: jMethodID=nil;
  5.   jCls: jClass=nil;
  6.   byteArray: jByteArray;
  7.   //AStr: AnsiString;
  8. begin
  9.   //jParams[0].l:= env^.NewStringUTF(env, PChar(_Text)); //  works well with ASCII, but with other encodings, sometimes it works with errors, the application crashes
  10.   //jParams[0].l:= env^.NewString{UTF}(env, PJChar(UTF8Decode(_Text)), Length(_text)); // sometimes the tail appears as unnecessary text characters
  11.   byteArray:= env^.NewByteArray(env, Length(_text));  // allocate
  12.   env^.SetByteArrayRegion(env, byteArray, 0, Length(_text), PJByte(_text));
  13.   jParams[0].l := byteArray;
  14.   jParams[1].f:= _x;
  15.   jParams[2].f:= _y;
  16.   jCls:= env^.GetObjectClass(env, _jdrawingview);
  17.   jMethod:= env^.GetMethodID(env, jCls, 'DrawText', '([BFF)V' {'(Ljava/lang/String;FF)V'});
  18.   env^.CallVoidMethodA(env, _jdrawingview, jMethod, @jParams);
  19.   env^.DeleteLocalRef(env, jParams[0].l);
  20.   env^.DeleteLocalRef(env, jCls);
  21. end;  
  22.  
Title: Re: Android Module Wizard
Post by: jmpessoa on October 13, 2019, 01:41:59 am

@kordal

Suggestions/improvements commiteds!!!

Thank you!
Title: Re: Android Module Wizard
Post by: kordal on October 24, 2019, 12:40:07 am
I updated jDrawingView and added methods for working with shaders: BitmapShader, LinearGradient, RadialGradient, SweepGradient. I'll post the source code a bit later.

upd. Redid everything and put it out in a separate component JPaintShader that works with JCanvas, JDrawingView

Example:
Title: Re: Android Module Wizard
Post by: jmpessoa on October 24, 2019, 04:03:40 am

Great!

Quote
I'll post the source code a bit later.

If possible, please, post the complete ".pas"  and ".java" units as attachments.

Thank you!


Title: Re: Android Module Wizard
Post by: Segator on November 06, 2019, 03:32:21 pm
Hi all, its posible to convert or get the real file path from a content uri like content://... to /strorage/sdcard...
Title: Re: Android Module Wizard
Post by: kordal on November 08, 2019, 01:44:53 am
@Segator, hi) Maybe ?
Code: Pascal  [Select][+][-]
  1. Self.GetInternalAppStoragePath(): String // get application path
  2. Self.GetEnvironmentDirectoryPath(dirDCIM): String // ex. get DCIM directory, return: /storage/emulated/0/DCIM
  3. (* TEnvDirectory = (dirDownloads,
  4.                     dirDCIM,
  5.                     dirMusic,
  6.                     dirPictures,
  7.                     dirNotifications,
  8.                     dirMovies,
  9.                     dirPodcasts,
  10.                     dirRingtones,
  11.                     dirSdCard,  // <------------------------------- sdcard
  12.                     dirInternalAppStorage,
  13.                     dirDatabase,
  14.                     dirSharedPrefs,
  15.                     dirCache); *)  

@jmpessoa, I finally finished working on a new component - JPaintShader, which works in tandem with JCanvas or JDrawingView. As promised, here are the sources (http://unimods.club/JPaintShader.7z) and some new demos. I hope I haven’t forgotten anything  :)
Title: Re: Android Module Wizard
Post by: Segator on November 08, 2019, 04:54:37 pm
@kordal, hi thats is good for fixed path but i am talking about convert a content uri from a intent activity like when you open an imagen file with your app the system send a uri string like content://media/external/images/media/112 but this content have a real file path like /storage/sdcard/Pictures/imagen.jpg so i want to convert it content uri to the real path
Title: Re: Android Module Wizard
Post by: Segator on November 08, 2019, 05:06:10 pm
I found this but is a java code  %) :
Code: Java  [Select][+][-]
  1. public class getRealPathUtil {
  2.  
  3.         @ @TargetApi(Build.VERSION_CODES.KITKAT)
  4.         public static String getRealPathFromURI_API19(Context context, Uri uri){
  5.                 String filePath = "";
  6.                 String wholeID = DocumentsContract.getDocumentId(uri);
  7.              String id = wholeID.split(":")[1];
  8.  
  9.              String[] column = { MediaStore.Images.Media.DATA };    
  10.  
  11.              // where id is equal to            
  12.              String sel = MediaStore.Images.Media._ID + "=?";
  13.  
  14.              Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
  15.                                        column, sel, new String[]{ id }, null);
  16.              int columnIndex = cursor.getColumnIndex(column[0]);
  17.              if (cursor.moveToFirst()) {
  18.                  filePath = cursor.getString(columnIndex);
  19.              }
  20.              cursor.close();
  21.              return filePath;
  22.         }
  23.        
  24.        
  25.         public static String getRealPathFromURI(Context context, Uri contentUri) {
  26.                   Cursor cursor = null;
  27.         try {
  28.             String[] proj = { MediaStore.Images.Media.DATA };
  29.             cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
  30.             cursor.moveToFirst();
  31.            int column_index = cursor.getColumnIndex(proj[0]);
  32.             String path = cursor.getString(column_index);
  33.             return path;
  34.         } finally {
  35.             if (cursor != null) {
  36.                 cursor.close();
  37.             }
  38.         }
  39.                   return result;  
  40.         }
  41.        
  42. }
  43.  
can be implemented in LAMW?
Title: Re: Android Module Wizard
Post by: jmpessoa on November 08, 2019, 08:02:04 pm
Quote
can be implemented in LAMW?

Yes!  i will implement them as jForm methods...

Thank you!
Title: Re: Android Module Wizard
Post by: kordal on November 11, 2019, 01:09:18 am
@jmpessoa, Have you looked at the source (http://unimods.club/JPaintShader.7z) ? And then the post remained unanswered, suddenly did not notice the link)
Title: Re: Android Module Wizard
Post by: jmpessoa on November 11, 2019, 03:07:13 am

Hi, kordal!

Yes!

Great work!

I will commit your code!  [as soon as possible!]

Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on November 11, 2019, 05:41:18 am
@Segator
Quote
I found this but is a java code

Done!

implement as jForm methods...

Code: Pascal  [Select][+][-]
  1. var
  2.   Uri: jObjectRef;
  3. begin
  4.      ....................
  5.  
  6.      ShowMessage(Self.GetRealPathFromURI(Uri));
  7.  
  8.      ............................................
  9. end;
  10.  
Title: Re: Android Module Wizard
Post by: Segator on November 11, 2019, 03:20:09 pm
@Segator
Quote
I found this but is a java code

Done!

implement as jForm methods...

Code: Pascal  [Select][+][-]
  1. var
  2.   Uri: jObjectRef;
  3. begin
  4.      ....................
  5.  
  6.      ShowMessage(Self.GetRealPathFromURI(Uri));
  7.  
  8.      ............................................
  9. end;
  10.  

Thats is great!, very thank to you.
Title: Re: Android Module Wizard
Post by: kordal on November 11, 2019, 11:01:07 pm
Hi, jmpessoa! It`s ok, thanks. I modified my example and adding new (SetRotate) overload method.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 12, 2019, 01:53:37 am

Quote
I modified my example ....

In time!

Commited!

Thank you
Title: Re: Android Module Wizard
Post by: kordal on November 12, 2019, 09:02:18 pm
Very well! good news, thank you :)
Title: Re: Android Module Wizard
Post by: kordal on November 21, 2019, 05:25:52 am
Hi jmpessoa! After updating LAMW, a bug got out of the repository. In previous versions of this was not observed. I venture to suggest that the name of the original file is taken from the component class name, which is written in Pascal, and not just copied from LAMW. What for? Java source file names are case sensitive.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 21, 2019, 07:39:26 am

Quote
I venture to suggest that the name of the original file is taken from the component class name, which is written in Pascal,....

Terrible! I have no idea where this can happen ...   %)
Title: Re: Android Module Wizard
Post by: jmpessoa on November 21, 2019, 11:44:47 pm

Fixed  ["a short term solution"]

("smartdesigner.pas"   line 1606....)

add suppport to 'J' [upcase] in componet  class name...as in "JPaintShader"
Title: Re: Android Module Wizard
Post by: kordal on November 22, 2019, 02:37:36 am
Thanks for the help. We will find out where this mysterious mistake came from.
Title: Re: Android Module Wizard
Post by: kordal on November 22, 2019, 07:27:55 am
Your method did not work. I found a more elegant solution that does not limit the case of writing components. Original JAVA files remain with their names and are not renamed based on the component name.

So, the problem was this:
SmartDesigner.pas
Code: Pascal  [Select][+][-]
  1. // ... line 1863
  2. if FileExists(LamwGlobalSettings.PathToJavaTemplates + jclassname + '.java') then
  3.    begin
  4.      list.LoadFromFile(LamwGlobalSettings.PathToJavaTemplates + jclassname + '.java');
  5.      list.Strings[0]:= 'package ' + FPackageName + ';';
  6.      list.SaveToFile(FPathToJavaSource + jclassname + '.java'); // In my case jclassname = JPaintShader, the original jPaintShader.java file. Crash!
  7.                                                                                           // Since FileExists is not case sensitive, the code worked.
  8. // ...
  9.  

What i suggest:
Code: Pascal  [Select][+][-]
  1. // returns the original file name from the JAVA template directory
  2. // ex: JClasSs = class(JControl) -> jClass.java
  3. function TLamwSmartDesigner.IsCorrectFileName(const Path, FileName: String): String;
  4. var
  5.   SR: TSearchRec;  
  6. begin
  7.   Result := FileName;
  8.   if FindFirst(Path + FileName, faAnyFile, SR) = 0 then
  9.     Result := SR.Name;
  10.   FindClose(SR);
  11. end;      
  12.  
  13. // ...
  14. if FileExists(LamwGlobalSettings.PathToJavaTemplates + jclassname + '.java') then
  15.    begin
  16.      list.LoadFromFile(LamwGlobalSettings.PathToJavaTemplates + jclassname + '.java');
  17.      list.Strings[0]:= 'package ' + FPackageName + ';';
  18.      list.SaveToFile(FPathToJavaSource + IsCorrectFileName(LamwGlobalSettings.PathToJavaTemplates, jclassname + '.java'));
  19.      // classes can now be written case-insensitively :)
  20. // ...
  21.  

The classes can now be written case-insensitively, file names are taken from the JAVA template directory. On Linux, this should also work because TSearchRec is cross-platform, but I have not tested it.
Title: Re: Android Module Wizard
Post by: jmpessoa on November 22, 2019, 07:32:41 am
Ok, kordal!

I will try your solution!

Thank you!

[Edited]
    Commited!!!
Title: Re: Android Module Wizard
Post by: m4u_hoahoctro on January 06, 2020, 11:48:00 am
@jmpessoa

Can you write a guide on how to make an own component into lamw ?

I have a while on using flutter and its experience on app seem be more native than lamw's, but making an app with lamw still be easier, hope we can have more components for use :) (May i will contribute for some examples of IoT/Arduino/ARM/AVR :) )
Title: Re: Android Module Wizard
Post by: kordal on January 09, 2020, 01:26:31 am
Directories & Files:
...\lazandroidmodulewizard\android_bridges\  - directory to Pascal components realization
register_ ... .pas - component registration files (if uses LAMW wizard, edited automaticly)
*.lrs - icon files of components

..\lazandroidmodulewizard\android_wizard\smartdesigner\java\ - directory to Java components realization
*.create - component initialization code
*.java - component main code
*.native - component event procedures
*.relational - list of *.java files (dependencies), if used in the main module java component

How to start?

Note: When you write bridge functions in Pascal, pay attention to the names of functions in Java code and how they are called in JNI. A prerequisite is the presence of signatures for functions that change depending on the input / output parameters (arguments).

Example (the example is not complete):
jMyComponent.java
Code: Java  [Select][+][-]
  1. // package org.lamw...; // changes automatically  
  2. //
  3. // skip two lines
  4.  
  5. import android.os.Bundle;
  6. // other imports
  7. // see https://developer.android.com/reference
  8.  
  9. public class jMyComponent {
  10.     // Java-Pascal Interface
  11.     private long     pascalObj   = 0;    // Pascal Object
  12.     private Controls controls    = null; // Java/Pascal [events] Interface ...
  13.     private Context  context     = null;
  14.  
  15.     // constructor
  16.    public jMyComponent(Controls _Ctrls, long _Self /*, other parameters*/ ) {
  17.                 context   = _Ctrls.activity;
  18.                 controls  = _Ctrls;
  19.                 pascalObj = _Self;
  20.                
  21.    }
  22.  
  23.   // destructor
  24.   public void jFree() {
  25.      // free local objects...
  26.   }
  27.  
  28.   public int Sum(int a, int b) {
  29.      return a + b;
  30.   }
  31.  
  32. }
  33.  

MyComponent.pas
Code: Pascal  [Select][+][-]
  1.   // ...
  2. type  
  3.   jMyComponent = class(...)
  4.     // initialization code
  5.     // ...
  6.     function Sum(a, b: Integer): Integer;
  7.   end;
  8.  
  9.   function jMyComponent.Sum(a, b: Integer): Integer;
  10.   begin
  11.     if FInitialized then
  12.       Result := jMyComponent_Sum(FjEnv, FjObject, a, b);
  13.   end;
  14.  
  15.   // JNI implementation
  16.   function jMyComponent_Sum(env: PJNIEnv; _jmycomponent: JObject; _a, _b: Integer): Integer;
  17.   var
  18.     jParams: array[0..1] of JValue;
  19.     jMethod: JMethodID = nil;
  20.     jCls   : JClass = nil;      
  21.   begin
  22.     jParams[0].i := _a;
  23.     jParams[1].i := _b;
  24.     jCls := env^.GetObjectClass(env, _jmycomponent);
  25.     jMethod := env^.GetMethodID(env, jCls, 'Sum', '(II)I'); // function name 'Sum', signature (I - integer, I - integer) result Integer  
  26.     Result := env^.CallIntMethodA(env, _jmycomponent, jMethod, @jParams);
  27.     // env^.CallVoidMethodA(env, _jmycomponent, jMethod, @jParams);  // no result
  28.     // env^.CallVoidMethod(env, _jmycomponent, jMethod);  // no result, no params
  29.     // env^.CallFloatMethodA(env, _jmycomponent, jMethod, @jParams);  // result float, with params
  30.    
  31.    // See more And_jni.pas & other components
  32.     env^.DeleteLocalRef(env, jCls);                                  
  33.   end;
  34.  
  35.   // signatures
  36. (*  
  37.  
  38.   Z - Boolean
  39.   B - Byte
  40.   I - Integer
  41.   F - Float (Single)
  42.   V - Void (no result)
  43.   L - java Object
  44.   [ - array, ex [I - integer array, [F - float array, etc.
  45.  
  46. *)
  47.  

To view signatures of compiled java files, you can use, for example, JCSign (http://unimods.club/JCSign.7z) tool.

Official help:

Quote
"LAMW: Lazarus Android Module Wizard"

   Author: Jose Marques Pessoa

      https://github.com/jmpessoa/lazandroidmodulewizard

:: How to Create JNI Bridge Component code::
 
1. LAMW Component Model: 

   ::  jControl: No GUI Control     

       hint: you can use composition or inheritance model here....

   ::  jVisualControl: GUI Control

       warning:  you MUST use inheritance model here.....

2. Creating a new component:
     
   2.1. Right click Java tab:

   2.1. Insert a new [wrapper] java class  jControl/jVisualControl from template;

        hint1. Alternatively, you can paste you java code [template compatible] from clipboard!

        hint2. Alternatively, you can import a "JAR" file and selec a class [at the moment, only for no visual  control]!

        hint3: You can also use the demo AppTryCode3 to produce a complete [wrapper]  java class !

       hint4. you do not need to build the "perfect" component now .... later you can add more methods, events and properties! [sections 3 e 4 bellow]

        warning/important: All "imports" from "Controls.java" template  and new "imports" from you java class code
                   will  be researched to try write the correct JNI methods signatures.....

                     
   2.2. Rename [and extends] the new class [and constructor], write some custom field, methods, etc...
        [for "JAR" imported class this task is automated! ]
       
        guideline: please, preferentially init your news params names with "_", ex: int _flag, String _hello ...
         
        hint1: Only public methods will be translated to pascal [bridge] code.
        hint2:  use the  mask  /*.*/   to make a public method invisible for the parse [ex.  /*.*/public myfunctio() {....} ] 

   2.3. Select all  the new java class code and right click it [java tab] .
     
       hint1:  if have only one java class code you do not need select it! just right click it!
       hint2. save your java class source code in LAMW folder "......\android_wizard\smartdesigner\java" :

        warning:  the  LAMW java to pascal convert dont support complex/generic types like  "java.util.Map<,>" ,  "java.util.Set<>" etc..
       So, we need re-write  the method signature [by hand] for primitives data/array type....

      But simple java Object param [or return]  is ok   [including array!!!]!
     
      public void SetImage(Bitmap _image) {     //<<----  OK!
             this.setImage(_image);
      }
 
     public Bitmap GetImage(Bitmap _image) {     //<<---- OK!
             return this.getImage();
      }

       warning/important: All "imports" from "Controls.java" template  and new "imports" from you java class code
                   will  be researched to try write the correct JNI methods signatures.....
     
   2.4. Popup Menu: Select "Write [Draft] Pascal jControl/jVisualControl Interface".
 
   2.5. Right click Pascal Tab  and select "Register Component..." from  Popup Menu;

          warning: Mac users: please, you must copy the console app "lazres" [lazarus/tools] to the folder
          ".../LazAndroidWizard/ide_tools";

   2.6. [Dialog]:  select a 16x16 PNG icon file;

   2.7.  [Dialog]:  open a "register_*.pas" file (ex. "register_extra.pas"); **

      hint: you can select "register_template.pas" to write a custom register file,
              but, then,  you must insert it into  "tfpandroidbridge_pack.lpk".

   2.8. Ok. You got you DRAFT pascal component JNI stuff! Please, look in the folder   "..../LazAndroidWizard/android_bridges"
         directory:
         
        :: *.pas           <--- open and fix/complete the pascal code with your others events/properties/methods/variables/overload!

        :: *_icon.lrs    <--- new icon resource
        :: register_extras.pas   <--- updated!  by default, the new component will be include there!

   2.9. [Lazarus IDE Menu]: Package -> Open Package File (*.lpk) --> "tfpandroidbridge_pack.pas" in folder 
         "....../LazAndroidWizard/android_bridges".

   2.10. [Package Wizard]: Compile --->> Use ---> Install.

            Warning: to compile/install/reinstall a LAMW package in  Lazarus/Laz4Android [windows],
               please, open a "dummy" pure windows project.... you MUST always close the cross compile project!
   
   2.11. Wait .... Lazarus re-building ...

   2.12. The new component  is on "Android Bridges Extra" [or other...] palette!.
   
   3. Added more methods to your component   

   3.1.  write new method to  your ".java" code
           ex.
                 public void SetFoo(int _foo) {
                       mFoo = _foo;
                 }
                  public int GetFoo() {
                        return mFoo;
                  }

   3.1.  In java tab write a draft java class code to wrapper the [new] methods;

           class jMyComponent {

                 public void SetFoo(int _foo) {
                       mFoo = _foo;
                 }
                  public int GetFoo() {
                        return mFoo;
                  }
          }                 
           
    3.2   Right click the Java tab and select "Write [draft] complementary Pascal Interface"

    3.4   Copy the the pascal interface code to your component unit!!!
       
    4. Added "native" [events] methods to your component

    4.1.  write the native method "call" to to  your ".java" code    [study some LAMW code as example!]

               ex1:   [from jSpinner.java]
 
                controls.pOnSpinnerItemSelected(pascalObj,position,caption);   //return void

              ex2:   [fiction...]
                int  i = controls.pOnSpinnerItemSelected(pascalObj,position,caption);   //return int             
 
              ex3:   [fiction...]
                int[] v;
                 v = controls.pOnSpinnerItemSelected(pascalObj,position,caption);   //return int[]     
                 for (int i = 0; i < v.length; i++) {
                     //Log.i("v["+i+"]", ""+v);     //do some use...
                 }         
               
              ex4:   [fiction...]
                String[] s;
                 s = controls.pOnSpinnerItemSelected(pascalObj,position,caption);   //return String[]               
                for (int i = 0; i < s.length; i++) {
                     //Log.i("s["+i+"]", ""+s);     //do some use...
                 }         
 
    4.2.  write the native method signature to your [component] ".native" file    [study some LAMW code as example!]
           ex1.    [from jSpinner.native]       
              public native void pOnSpinnerItemSelected(long pasobj, int position, String caption);

           ex2.    [fiction...]       
              public native int pOnSpinnerItemSelected(long pasobj, int position, String caption);

           ex3.    [fiction...]       
              public native int[] pOnSpinnerItemSelected(long pasobj, int position, String caption);

           ex4.    [fiction...]       
              public native String[] pOnSpinnerItemSelected(long pasobj, int position, String caption);

    4.3.  In java tab write a draft java class code to wrapper the the native [one line!] method;
         
           class jMyComponent {

                public native void pOnMyComponentItemSelected(long pasobj, int position, String caption); //MyComponent

          }                 

         NOTE: the  "//MyComponent" signs the part of the method name that will be overshadowed in the nomination of the property.
                            ex.  FOnItemSelected   [ not FOnMyComponentItemSelected  ]   

    4.4   Right click the Java tab and select "Write [draft] complementary Native Method Pascal Interface"

    4.5   Copy the the pascal interface code [generated] to your component unit [mycomponent.pas] and to "Laz_And_Controls_Events.pas"!!!

    Congratulations!!!     

Title: Re: Android Module Wizard
Post by: Mongkey on January 10, 2020, 11:36:35 am
Thanks bro, your tools are awesome!

cant wait for new advanced cool bridge :D
Title: Re: Android Module Wizard
Post by: kordal on January 23, 2020, 11:49:40 am
Hi @jmpessoa, @TR3E  :)
1. There is an error in the
Code: Pascal  [Select][+][-]
  1. function GetTimeInMilliseconds: Longint
function, it returns a negative value! The fact is that the Integer type does not have enough bit depth for the correct operation of the time counter.

The problem arises is data types on the Pascal side. GetTimeInMilliseconds is of type Longint = Integer = jInt = Int (java), and should be Int64 = jLong = Long (java). As a result, the function calls another jni_func_out_j, where there is also a problem with data types.

So, we have at least several problematic calling functions
Code: Pascal  [Select][+][-]
  1. function jni_func_out_j: Longint; // change Longint to Int64
  2. function jni_func_j_out_t(..: Longint) ...; // change Longint to Int64
, where the types Longint and Int64 are mixed up.

2. I`am updated the jDrawingView component. The OnClick and OnDoubleClick events have been added.
So, the first modification:
Controls.java, added to line 165, 166
Code: Java  [Select][+][-]
  1. class Const {
  2.   public static final int TouchDown            =  0;
  3.   public static final int TouchMove            =  1;
  4.   public static final int TouchUp              =  2;
  5.   public static final int Click                =  3; // new
  6.   public static final int DoubleClick          =  4;  // new
  7.   public static final int Click_Default        =  0;
  8. }
  9.  
AndroidWidget.pas, added to line 71, 72 and two new functions
Code: Pascal  [Select][+][-]
  1. // Event id for Pascal & Java
  2.   cTouchDown            = 0;
  3.   cTouchMove            = 1;
  4.   cTouchUp              = 2;
  5.   cClick                = 3;
  6.   cDoubleClick          = 4;
  7.  
  8. // ...
  9.   procedure jni_proc_s(env: PJNIEnv; _jobject: JObject; javaFuncion : string; _short: smallint);
  10.   procedure jni_proc_ss(env: PJNIEnv; _jobject: JObject; javaFuncion : string; _short1, _short2: smallint);
  11.  
  12. // ...
  13. implementation
  14. // ...
  15.   procedure jni_proc_s(env: PJNIEnv; _jobject: JObject; javaFuncion : string; _short: smallint);
  16.   var
  17.     jParams: array[0..0] of jValue;
  18.     jMethod: jMethodID = nil;
  19.     jCls   : jClass = nil;
  20.   begin
  21.     jParams[0].s:= _short;
  22.  
  23.     jCls := env^.GetObjectClass(env, _jobject);
  24.     jMethod := env^.GetMethodID(env, jCls, PChar(javaFuncion), '(S)V');
  25.     env^.CallVoidMethodA(env, _jobject, jMethod, @jParams);
  26.     env^.DeleteLocalRef(env, jCls);
  27.   end;
  28.  
  29.   procedure jni_proc_ss(env: PJNIEnv; _jobject: JObject; javaFuncion : string; _short1, _short2: smallint);
  30.   var
  31.     jParams: array[0..1] of jValue;
  32.     jMethod: jMethodID = nil;
  33.     jCls   : jClass = nil;
  34.   begin
  35.     jParams[0].s:= _short1;
  36.     jParams[1].s:= _short2;
  37.  
  38.     jCls := env^.GetObjectClass(env, _jobject);
  39.     jMethod := env^.GetMethodID(env, jCls, PChar(javaFuncion), '(SS)V');
  40.     env^.CallVoidMethodA(env, _jobject, jMethod, @jParams);
  41.     env^.DeleteLocalRef(env, jCls);
  42.   end;    
  43.  

The following modification affected JDrawingView.java and DrawingView.pas, modified files in the attached.
Title: Re: Android Module Wizard
Post by: ADiV on January 24, 2020, 09:29:08 am
Updated "jDrawingView" [thanks to Kordal]

Fixed "GetTimeInMilliseconds" long to int64 and the corresponding "jni_func".

I have changed the variables that were in capital letters, since in programming the constants are understood as capital, when it will not be so.

And I have changed the FTimeClick and FTimeDoubleClick variables from short to int.

Already uploaded to LAMW as "Pull request", it is necessary that jmpessoa accept it.

Title: Re: Android Module Wizard
Post by: kordal on January 24, 2020, 01:26:30 pm
Thank you) I forgot to add line in the Init procedure. This is necessary to change property values ​​in component design time.
Code: Pascal  [Select][+][-]
  1. procedure jDrawingView.Init(refApp: jApp);
  2. // ...
  3. begin
  4.   // ...
  5.   if not FInitialized then
  6.   begin
  7.     // ...
  8.     jni_proc_ii(FjEnv, FjObject, 'SetTimeClicks', FTimeClick, FTimeDoubleClick);
  9.   end;
  10. end;
  11.  
Title: Re: Android Module Wizard
Post by: ADiV on January 24, 2020, 02:10:32 pm
Ok, it's already uploaded.
Title: Re: Android Module Wizard
Post by: nullpointer on March 07, 2020, 02:58:33 pm
How to build Android App Bundles?

i'm trying to upload my app to Play Store and got following error

This release does not comply with the 64-bit Google Play requirements

The following APK or App Bundle is available for 64-bit devices, but only has 32-bit native code: 2.

Enter 64-bit and 32-bit native code in your application. Use the Android App Bundle publication format to ensure directly that each device architecture only accepts the required native code. This will prevent the addition of the overall application size.

https://developer.android.com/guide/app-bundle?hl=en (https://developer.android.com/guide/app-bundle?hl=en)

please help...
Title: Re: Android Module Wizard
Post by: Manlio on March 13, 2020, 04:11:48 am
How to build Android App Bundles?

Not using Android App Bundles is NOT the reason why your app is rejected by Google Play (see below for the real reason).

Android App Bundles (AAP files) are the *recommended* format by google, but APK files are accepted.

Android App Bundles's (AAB) advantage over APK is this: when people will download your app from google's play store, if you uploaded your app in AAB format, the user will only receive one version of the library, the one they need: downloading to a 64-bit phone will get only the 64 bit library, and downloading to a 32-bit device will get only the 32-bit files. If instead you uploaded your app as APK, all the users will receive all the files, 32 and 64  bit. I think they call that a "fat" bundle.

So AAP files are better for your users (no space wasted on their memory and in downloaded bandwidth). But APK are still accepted.

In order to create AAB bundles, I believe you need to use Android Studio to build the app, although I hope that at some point the Lazarus package will become able to do that as well.

But my suggestion is to stick with APK for the time being. You already have enough complicated things to work out, and you don't need one more...

And now the important thing:

This release does not comply with the 64-bit Google Play requirements

The reason why you app was not accepted is that it didn't contain a 64-bit version of the library.

By default, LAMW/Lazarus generates 32-bit version of the library (libcontrols.so is the default name) which contains the Pascal code you write with LAMW.

Since August 2019, google requires a 64 bit version of any native libraries (so files) and refuses to accept APK (or AAB) files that only contain 32-bit versions of embedded libraries.

32-bit libraries are stored in the folder "libs\armeabi-v7a" in your app's main folder.

(you will probably see the file libcontrols.so in that folder)

64-bit libraries are stored in the folder "libs\arm64-v8a" in your app's main folder.

(you will probably find this folder empty)

What you need to do to get your app accepted by google is to set up a separate 64-bit FPC compiler, which targets arm64 CPUs, and compile your project a second time with it, so that the 64-bit file will be created and added to the libs\arm64-v8a folder.

I had to struggle a lot to figure this out. More recently, fpdeluxe and other projects are making the task of building both 32 and 64 bit versions easier.

In my case, Lazarus IDE now produces a 32 bit library, and then I separately call a script that compiles the project again, with the 64 bit compiler this time.

At that point, both of the above folders will have the libcontrols.so file in them. If you then build the APK, both versions (32 bit and 64 bit) will be included in the APK. And when you will submit it to google, it will be accepted.

Title: Re: Android Module Wizard
Post by: DonAlfredo on March 13, 2020, 05:14:35 am
Hi,

A week ago, I have added a Gradle option into build.gradle:

Quote
    splits {
        abi {
            enable true
            reset()
            include 'arm64-v8a'
            universalApk false
        }
    }

To make a combined apk, build with Gradle and use this:

Quote
    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a','arm64-v8a'
            universalApk true
        }
    }

If needed, I can put this (mutli-arch apk) into LAMW as a new feature.
Title: Re: Android Module Wizard
Post by: ASBzone on March 13, 2020, 05:52:51 pm
In my case, Lazarus IDE now produces a 32 bit library, and then I separately call a script that compiles the project again, with the 64 bit compiler this time.

At that point, both of the above folders will have the libcontrols.so file in them. If you then build the APK, both versions (32 bit and 64 bit) will be included in the APK. And when you will submit it to google, it will be accepted.

You can use Build Modes so that you can perform both compilations from the GUI consecutively, if you'd like.

https://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Build_modes (https://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Build_modes)
Title: Re: Android Module Wizard
Post by: nullpointer on April 03, 2020, 12:09:14 pm
How to build Android App Bundles?

Not using Android App Bundles is NOT the reason why your app is rejected by Google Play (see below for the real reason).

Android App Bundles (AAP files) are the *recommended* format by google, but APK files are accepted.

Android App Bundles's (AAB) advantage over APK is this: when people will download your app from google's play store, if you uploaded your app in AAB format, the user will only receive one version of the library, the one they need: downloading to a 64-bit phone will get only the 64 bit library, and downloading to a 32-bit device will get only the 32-bit files. If instead you uploaded your app as APK, all the users will receive all the files, 32 and 64  bit. I think they call that a "fat" bundle.

So AAP files are better for your users (no space wasted on their memory and in downloaded bandwidth). But APK are still accepted.

In order to create AAB bundles, I believe you need to use Android Studio to build the app, although I hope that at some point the Lazarus package will become able to do that as well.

But my suggestion is to stick with APK for the time being. You already have enough complicated things to work out, and you don't need one more...

And now the important thing:

This release does not comply with the 64-bit Google Play requirements

The reason why you app was not accepted is that it didn't contain a 64-bit version of the library.

By default, LAMW/Lazarus generates 32-bit version of the library (libcontrols.so is the default name) which contains the Pascal code you write with LAMW.

Since August 2019, google requires a 64 bit version of any native libraries (so files) and refuses to accept APK (or AAB) files that only contain 32-bit versions of embedded libraries.

32-bit libraries are stored in the folder "libs\armeabi-v7a" in your app's main folder.

(you will probably see the file libcontrols.so in that folder)

64-bit libraries are stored in the folder "libs\arm64-v8a" in your app's main folder.

(you will probably find this folder empty)

What you need to do to get your app accepted by google is to set up a separate 64-bit FPC compiler, which targets arm64 CPUs, and compile your project a second time with it, so that the 64-bit file will be created and added to the libs\arm64-v8a folder.

I had to struggle a lot to figure this out. More recently, fpdeluxe and other projects are making the task of building both 32 and 64 bit versions easier.

In my case, Lazarus IDE now produces a 32 bit library, and then I separately call a script that compiles the project again, with the 64 bit compiler this time.

At that point, both of the above folders will have the libcontrols.so file in them. If you then build the APK, both versions (32 bit and 64 bit) will be included in the APK. And when you will submit it to google, it will be accepted.

thank you for your complete answer.
Title: Re: Android Module Wizard
Post by: Robert Gilland on April 08, 2020, 12:28:47 am
Any Idea why I would get : Didn't find class "robert.gilland.moviemaster.jFileProvider?


E/AndroidRuntime( 6442): FATAL EXCEPTION: main

E/AndroidRuntime( 6442): java.lang.RuntimeException: Unable to get provider robert.gilland.moviemaster.jFileProvider: java.lang.ClassNotFoundException: Didn't find class "robert.gilland.moviemaster.jFileProvider" on path: DexPathList[[zip file "/data/app/robert.gilland.moviemaster-2.apk"],nativeLibraryDirectories=[/data/app-lib/robert.gilland.moviemaster-2, /vendor/lib, /system/lib]]

E/AndroidRuntime( 6442):    at android.app.ActivityThread.installProvider(ActivityThread.java:5100)

I am stumped
Title: Re: Android Module Wizard
Post by: jmpessoa on April 09, 2020, 03:09:02 am

Quote
Any Idea why I would get : Didn't find class "robert.gilland.moviemaster.jFileProvider?

Are you using some jFileProvider component in your projet?

If so,  delete it and put it again...
Title: Re: Android Module Wizard
Post by: Robert Gilland on April 13, 2020, 01:25:32 am
Thank you got through that hurdle.

Now I am trying to  use demo "appmenudemo2" on an API 17 device using latest GIT version of LAMW and I get the following:

E/AndroidRuntime(25858): FATAL EXCEPTION: main

E/AndroidRuntime(25858): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to com.android.internal.view.menu.ActionMenuView$LayoutParams

Kind Regards,

Robert Gilland.
Title: Re: Android Module Wizard
Post by: Robert Gilland on June 06, 2020, 11:57:43 pm
Okay, I think I know the reason why I am getting these java class not found errors.

It is my lack of knowledge as how the java class repository is built up for the application.
I think it looks in all files that are in the".lpr" file or it could be as you add objects to form in the application.
Not sure.

But somehow the object was not in the java libraries for the application.
Title: Re: Android Module Wizard
Post by: shyub on July 07, 2020, 01:04:17 pm
Hello!
Tell me, please, is it possible to debug an Android application created using LAMV on a real device and how to do it.
Title: Re: Android Module Wizard
Post by: Guser979 on July 07, 2020, 02:48:58 pm
Hello!
Tell me, please, is it possible to debug an Android application created using LAMV on a real device and how to do it.


Good question. Sometimes I get lost at some point in a project because failures occur during execution on the device. I only started with LAMW a few days ago. I'm exploring Android Studio and LAMW. It is a fantastic work done by the authors of LAWM. I believe that with some effort I can do what I need.
Title: Re: Android Module Wizard
Post by: HotShoe on July 20, 2020, 10:25:07 pm
I have run into an oddity while using LAMW. I created a new LAMW GUI project and used a Jpanel and several jbitbuttons to re-create a dialer app that I wrote years ago. This is just to compare the 2 and see if there are any surprises.

Anyway. I saved my main unit as Main.pas as I always do, and I renamed the form to Mainfrm as I always do. Everything seemed fine until I had to shut everything down for a meeting. I saved everything and closed Lazarus.

When I came back, I could not load the project again. I get a Property "Caption" not found. I can still load the demo projects without a problem, so I created a new project again and placed the same components on the Jform again. This time I did not rename the main form, I lseft it a AndroidModule1, and I can close the ide , re-open it and it loads the project just fine.

I can't find any differences between the 2 projects that I created except the name of the main form, so I suspect this is not supported, or the renaming makes the project look like it is a standard Tform again? Jforms do not have a caption property, but do have a Text property. It's just a guess but something that will force me to change my normal naming practices.

I should add that I am using Lazarus 2.0.10 and FPC 3.2.0, the latest LAMW and the Arm and Aarch64 cross compilers.

Thanks,
--- Jem
Title: Re: Android Module Wizard
Post by: ketch on July 27, 2020, 08:36:03 pm
Hi guys,

for the past two weeks, i have been trying to implement admob Rewarded Ads starting with the good admob demo in LAMW.

Google documentation can be found here: https://developers.google.com/admob/android/rewarded-ads

I'm not a Java expert and modifying LAMW is an hard work. I've tried a lot of things but don't really know how to do this.

Please could you implement this for LAMW, that would be great.

Thanks.
Title: Re: Android Module Wizard
Post by: shyub on August 24, 2020, 04:58:08 pm
Dear friends!
Sorry for my English (translating with the help of Google translator).
Https://github.com/jmpessoa/lazandroidmodulewizard/issues/165 talked about BluetoothSPP. Recent versions of LAMW even have a jcBluetoothSPP component, but I can't figure it out. I have a big request, post an example using this component.
Title: Re: Android Module Wizard
Post by: shyub on August 24, 2020, 07:02:17 pm
Sorry.
The latest version of lazandroidmodulewizard posted this month at https://github.com/jmpessoa/lazandroidmodulewizard has an example AppJCenterBluetoothSPPDemo1.
Thanks to the developers!
Title: Re: Android Module Wizard
Post by: Guser979 on September 04, 2020, 12:12:48 am
an observation ... jcustomcamera has memory leak and Inevitable crash after certain time saving photos ... As I have to activate jcustomcam many times in my app, so I had to investigate. I don't know Java, but researching it, I discovered that it was a memory leak. After testing, I solved the problem with a line of code in jcustomcamera.java ....... bitmap.recycle (); added in private void saveBitmapToJpg (Bitmap bitmap, String bmpPath) ....exactly after outStream.close () ;. My app had no more problems. I hope I helped this fantastic work.
Title: Re: Android Module Wizard
Post by: jmpessoa on September 04, 2020, 03:22:10 am

@Guser979

Fixed!

Thank you!!!!
Title: Re: Android Module Wizard
Post by: jmpessoa on October 30, 2020, 07:13:42 pm
NEWS!

Version 0.8.6 [AndroidX]

LAMW Migrate Material Theme/AppCompat to AndroidX [by @ADiV]

Requires SDK 28 or higher
and
Gradle 6.6.1
 
(downloaded from: https://gradle.org/releases/)

Thanks to  @ADiV!!
Title: Re: Android Module Wizard
Post by: rsu333 on December 01, 2020, 03:33:10 pm
i am trying external file permission in Action Tab module but not success also adding Actionbar tab in share file modul but got error .
How can I use external storage permission  keeping actionbar tab [use of three panels].
exact which code is useful and where it to keep.
Title: Re: Android Module Wizard
Post by: jmpessoa on December 01, 2020, 08:04:04 pm

Quote
How can I use external storage permission...

You can see the code in demo "AppCameraDemo"  and others demos.....
Title: Re: Android Module Wizard
Post by: jmpessoa on June 28, 2021, 05:18:07 am
Hello All!

LAMW Ide-Tools:  NEW!  "Export LAMW Project as Template/Theme..."

Now you can use an entire project as a starting point for your nice new app....

Warning: Make sure that the project you want to use as template works perfectly.
Warning: Project Options/SearchPaths  -Fu  will not be exported!
Warning: secondary gApp.CreateForm in  ".lpr"  will not be exported** !

The Project Exported will be saved as LAMW template/theme in the Folder:

''....\android_wizard\smartdesigner\AppTemplates"

and can be selected in the next [LAMW] "New Project" as Theme!

Have Fun!

** hint: If need, put all secondary gApp.CreateForm in [main form] "OnActivityCreate" event.
Title: Re: Android Module Wizard
Post by: Mongkey on June 28, 2021, 06:44:54 am
 :), Thank you, saving a lot of time creating same theme.
Title: Re: Android Module Wizard
Post by: rsu333 on June 28, 2021, 03:15:36 pm
Your work is energetic for us.
Title: Re: Android Module Wizard
Post by: jmpessoa on July 23, 2021, 11:07:13 pm
Hi, All!

Now LAMW can handle "Firebase Cloud Messaging"  push notification!

NEW! "jsFirebasePushNotificationListener"  component

NEW!  demo:
AppCompatFirebasePushNotificationListenerDemo1

NEW! doc!
"how_to_handling_firebase_push_notification.txt"

Quote
How to: Handling Firebase Push Notification in LAMW  [warning: "beta" version ::  23-July-2021]
   (by jmpessoa)


0) Create your "AppCompat" [[theme]] project
   0.1)Put a "jsFirebasePushNotificationListener" component on form
        0.2)Go to lazarus menu and simply  "Run" --> "Build"

1) Login in your google acount [email or any....]

2) Go to "https://console.firebase.google.com/"

3) Create/Add a new Project   [ex: "MyOrg"]

4) Go to your "MyOrg" project and click "+Add app"

5) Click on Android Icon

6) In (page) "Add Firebase to your Android app":
   6.1) "Register App"
      6.1.1 ""Android package name"
         ex: org.lamw.appcompatfirebasepushnotificationlistenerdemo1

      6.1.2 CLICK the button "Register app"

   6.2) "Download config file"
                 get the "google-services.json" and put it in your LAMW project folder

        Done!

   (don't do anything more, LAMW takes care of it all for you!)

7) Active your Internet phone/device connection

8) Go to Lazarus menu "Run" --> "[LAMW] Build Android Apk and Run"

9) Go to "https://console.firebase.google.com/"

   9.1 Click the "MyOrg" project
   9.2 In the left panel/menu page go to "Engage" --> "Cloud Messaging"
   9.3 Click "New notification" Button
   9.4 Fill the form and click "Next"
   9.5 In the "Target" --> "selectan app"   [select your app package...] and "Next"
        9.6 In the "Scheduling" --> "Now"  and "Next"
        9.7 In the bottom page click the button "Review"
   9.8 "Publish"  !!!!


Congratulations!!!


10) Notes about your/custom Payload expected by LAMW component:
   [https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en]

10.1 Notification Payload


{
"message":{
-    ...
     ...
    "notification":{
      "title" : "my message title",     // ---> "title" expected by LAMW
      "body" : "my message body"        // ---> "body"  expected by LAMW
    }
    ...
    ...
  }
}

Note: Notification messages are delivered to the notification tray when the app is in the background.
For apps in the foreground, messages are handled/delivery by a LAMW callback function for you !!!


10.2 Data Payload

{
  "message":{
    ...
    ...
    "data":{
      "title":"my message title",// ---> "title" expected by LAMW
      "body":"my message body",  // ---> "body" expected by LAMW
      "myKey1":"myValue1"        //free/custom
      "myKey2":"myValue2"        //free/custom
       ......                    //free/custom
    }
    ...
    ...
  }
}

Where myKey1, myKey2, .... are your free/custom key=value pairs ....

warning: from "data" messages only "title" and "body" are handled/delivery by the LAMW callback function for you
         but you can read all "data" when App is "waking up" by clicking in notification....

//by code:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1ActivityCreate(Sender: TObject; intentData: jObject);
  2. var
  3.   data: TDynArrayOfString;
  4.   i, count: integer;
  5. begin
  6.   data:= jIntentManager1.GetBundleContent(intentData, '=');  //key=value
  7.   count:= Length(data);
  8.   for i:= 0 to count-1 do
  9.   begin
  10.      ShowMessage(data[i]);  //key=value
  11.   end;
  12. end;
  13.  

//and/or maybe:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1NewIntent(Sender: TObject; intentData: jObject);
  2. var
  3.   data: TDynArrayOfString;
  4.   i, count: integer;
  5. begin
  6.   data:= jIntentManager1.GetBundleContent(intentData, '=');  //key=value
  7.   count:= Length(data);
  8.   for i:= 0 to count-1 do
  9.   begin
  10.      ShowMessage(data[i]);  //key=value
  11.   end;
  12. end;
  13.  

10.3 Mixing Notification and Data Payload

{
  "message":{
    ...
    "notification":{
      "title" : "my message title",     // ---> "title" expected by LAMW
      "body" : "my message body"        // ---> "body"  expected by LAMW
    }
    "data":{
      "myKey1":"myValue1"        //free/custom
      "myKey2":"myValue2"        //free/custom
       ......
    }
    ...
    ...
  }
}


10.4  WARNING: "beta" version ::  23-July-2021

10.5 References

https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en


Thanks to All!
Title: Re: Android Module Wizard
Post by: Mongkey on August 08, 2021, 10:45:55 am
Is it posibble in near future LAMW modify firebase db? Just like FB4D  :)
Or just simply modifying by using javascript inside webview?

Thank you
Title: Re: Android Module Wizard
Post by: jmpessoa on August 09, 2021, 12:26:05 am

Quote
Is it posibble in near future LAMW modify firebase db

Yes, we can try implement firebase "db" ...

But let's clarify:
jsFirebasePushNotificationListener component is about  "Firebase Cloud Messaging"  push notification!
Title: Re: Android Module Wizard
Post by: Mongkey on August 09, 2021, 01:48:28 am
Ok, thank you
Title: Re: Android Module Wizard
Post by: jmpessoa on January 17, 2022, 07:49:21 pm
Hi, All!

Android 11 - Api 30  has restricted developers to access devices "publics" folders (ex: "Download, Documents, ..., etc")

Developers no longer have access to a file via its path. Instead, you need to use via “Uri“.

New!   jForm methods:

 //get user permission... and an uri
RequestCreateFile
RequestOpenFile
RequestOpenDirectory
procedure TakePersistableUriPermission

 //handling file by uri....
 function GetFileList                [edited...]
 function GetBitmapFromUri
 function GetTextFromUri
 procedure SaveImageToUri
 procedure SaveTextToUri

New demo:
"AppPublicFoldersAccessDemo1"
Title: Re: Android Module Wizard
Post by: neuro on March 12, 2022, 02:24:34 pm
//handling file by uri....
 function GetBitmapFromUri
 function GetTextFromUri
 procedure SaveImageToUri
 procedure SaveTextToUri

New demo:
"AppPublicFoldersAccessDemo1"

I have added function SaveBytesToUri.

The updated code is in attachment, in two files:
1) jForm.java, located at
C:\fpcupdeluxe\ccr\lamw\android_wizard\smartdesigner\java

2) androidwidget.pas, located at
C:\fpcupdeluxe\ccr\lamw\android_bridges


jmpessoa, please search the attached files for phrase “by neuro” and copy/paste new code into LAMW distribution files.

The new code in “androidwidget.pas”:
Code: Pascal  [Select][+][-]
  1. procedure SaveBytesToUri(_bytes: TDynArrayOfJByte; _toTreeUri: jObject); // by neuro
  2. procedure jForm_SaveBytesToUri(env: PJNIEnv; _jform: JObject; _bytes: TDynArrayOfJByte; _toUri: jObject); // by neuro
  3.  
  4. //by neuro
  5. procedure jForm.SaveBytesToUri(_bytes: TDynArrayOfJByte; _toTreeUri: jObject);
  6. begin
  7.   //in designing component state: set value here...
  8.   if FInitialized then
  9.      jForm_SaveBytesToUri(FjEnv, FjObject, _bytes ,_toTreeUri);
  10. end;
  11.  
  12. //by neuro
  13. procedure jForm_SaveBytesToUri(env: PJNIEnv; _jform: JObject; _bytes: TDynArrayOfJByte; _toUri: jObject);
  14. var
  15.   jParams: array[0..1] of jValue;
  16.   jMethod: jMethodID=nil;
  17.   jCls: jClass=nil;
  18.  
  19.   byteArray: jByteArray;
  20.   len: SizeInt;
  21.  
  22. label
  23.   _exceptionOcurred;
  24. begin
  25.  
  26.   jCls:= env^.GetObjectClass(env, _jform);
  27.   if jCls = nil then goto _exceptionOcurred;
  28.   jMethod:= env^.GetMethodID(env, jCls, 'SaveBytesToUri', '([BLandroid/net/Uri;)V');
  29.   if jMethod = nil then goto _exceptionOcurred;
  30.  
  31.   len := Length(_bytes);
  32.   byteArray:= env^.NewByteArray(env, len);
  33.   env^.SetByteArrayRegion(env, byteArray, 0 , len, @_bytes[0]);
  34.  
  35.   jParams[0].l:= byteArray;
  36.   jParams[1].l:= _toUri;
  37.  
  38.   env^.CallVoidMethodA(env, _jform, jMethod, @jParams);
  39.   env^.DeleteLocalRef(env,jParams[0].l);
  40.  
  41.   env^.DeleteLocalRef(env, jCls);
  42.  
  43.   _exceptionOcurred: jni_ExceptionOccurred(env);
  44. end;

The new code in “jForm.java”:
Code: Java  [Select][+][-]
  1.     //Android 11: //by neuro
  2.     public void SaveBytesToUri(byte[] _bytes, Uri _toTreeUri) {
  3.         OutputStream out=null;
  4.         try {
  5.             out = controls.activity.getContentResolver().openOutputStream(_toTreeUri, "w");
  6.  
  7.             out.write(_bytes);
  8.             out.flush();
  9.         } catch (FileNotFoundException e) {
  10.             e.printStackTrace();
  11.         } catch (IOException e) {
  12.             e.printStackTrace();
  13.         }
  14.     }  
  15.  
   


Usage example:
Code: Pascal  [Select][+][-]
  1. var
  2.   array_of_bytes: array of byte;
  3.   array_of_jbytes: TDynArrayOfJByte;
  4.   n, size_of_array: Integer;
  5.  
  6. begin  
  7.  
  8. size_of_array := 256;
  9. setLength(array_of_bytes, size_of_array);  
  10. setLength(array_of_jbytes, size_of_array);
  11.  
  12. for n := 0 to size_of_array-1 do
  13. begin
  14. array_of_bytes[n] := Byte(128); // here set the values of byte array
  15. array_of_jbytes[n] := JByte(array_of_bytes[n]);
  16. end;
  17.  
  18. Self.SaveBytesToUri(array_of_jbytes, treeUri);
  19.  
  20.  
  21. end;


We also need function
GetBytesFromUri
which is not yet available.

In sample project AppPublicFoldersAccessDemo1
two buttons work (“Request Create File” and “Request Open Directory”),
however third button “Request Open File” does not work – nothing happens when this button is pressed.
I guess this button should invoke system file picker (equivalent of open file dialog), however it does not work.
I am running AppPublicFoldersAccessDemo1 on Android 8.1 (device: Samsung Galaxy Tab A 10.1).
I have fixed this bug in the post below.
Title: Re: Android Module Wizard
Post by: neuro on March 12, 2022, 06:18:17 pm
I have fixed the bug in sample project AppPublicFoldersAccessDemo1.
The problem was that button “Request Open File” does not work.
The fixed code should be replaced in file “androidwidget.pas”, located at
C:\fpcupdeluxe\ccr\lamw\android_bridges

Code: Pascal  [Select][+][-]
  1. procedure jForm_RequestOpenFile(env: PJNIEnv; _jform: JObject; _uriAsString: string; _fileMimeType: string; _requestCode: integer);
  2. var
  3.   jParams: array[0..3] of jValue; // <<---- bug fixed
  4.   jMethod: jMethodID=nil;
  5.   jCls: jClass=nil;
  6. label
  7.   _exceptionOcurred;
  8. begin
  9.  
  10.   jCls:= env^.GetObjectClass(env, _jform);
  11.   if jCls = nil then goto _exceptionOcurred;
  12.   jMethod:= env^.GetMethodID(env, jCls, 'RequestOpenFile', '(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V'); // <<---- bug fixed
  13.   if jMethod = nil then goto _exceptionOcurred;
  14.  
  15.   jParams[0].l:= env^.NewStringUTF(env, PChar(_uriAsString));
  16.   jParams[1].l:= env^.NewStringUTF(env, PChar(_fileMimeType));
  17.   jParams[2].l:= env^.NewStringUTF(env, PChar(nil)); // <<---- bug fixed
  18.   jParams[3].i:= _requestCode;  // <<---- bug fixed
  19.  
  20.   env^.CallVoidMethodA(env, _jform, jMethod, @jParams);
  21.   env^.DeleteLocalRef(env,jParams[0].l);
  22.   env^.DeleteLocalRef(env,jParams[1].l);
  23.   env^.DeleteLocalRef(env,jParams[2].l); // <<---- bug fixed
  24.  
  25.   env^.DeleteLocalRef(env, jCls);
  26.  
  27.   _exceptionOcurred: jni_ExceptionOccurred(env);
  28. end;

jmpessoa, please update function “jForm_RequestOpenFile” in file “androidwidget.pas” with the fixed code above.


Another problem – in file:
C:\fpcupdeluxe\ccr\lamw\demos\GUI\AppPublicFoldersAccessDemo1\jni\unit1.pas
the code does not work:
Code: Pascal  [Select][+][-]
  1. //or if mimetype is "image/*"
  2. ImageView.SetImage(Self.GetBitmapFromUri(treeUri));

I suspect that the problem is inside file
C:\fpcupdeluxe\ccr\lamw\android_wizard\smartdesigner\java\jForm.java
in program code of function:
Code: Java  [Select][+][-]
  1. //Android 11:
  2. public Bitmap GetBitmapFromUri(Uri _treeUri)

However I still do not know how to fix it.
Title: Re: Android Module Wizard
Post by: jmpessoa on March 12, 2022, 09:38:46 pm

hi, neuro!

First: thank you!

But, if possible, can you submit a "pull request" for changes in github?
Title: Re: Android Module Wizard
Post by: neuro on March 12, 2022, 10:11:17 pm
But, if possible, can you submit a "pull request" for changes in github?

I have never used github before, I need to figure out how to do that, I’ll do that a little later.
Title: Re: Android Module Wizard
Post by: jmpessoa on March 13, 2022, 12:22:15 am
Quote
I have never used github before, I need to figure out how to do that, I’ll do that a little later.

Ok.  So,  please, send me all modified  ".pas"   and   ".java"  ... I will commit your changes...

(maybe you can "zip" all and put here....)


Thank you!

Title: Re: Android Module Wizard
Post by: neuro on March 13, 2022, 02:46:11 pm
can you submit a "pull request" for changes in github?

I have made two "pull requests" for changes in github for two files (jForm.java, androidwidget.pas).
Title: Re: Android Module Wizard
Post by: jmpessoa on March 13, 2022, 10:07:08 pm

Quote
I have made two "pull requests" for changes in github for two files (jForm.java, androidwidget.pas).

Done!


Thank you!
Title: Re: Android Module Wizard
Post by: jmpessoa on April 14, 2022, 12:46:48 am
Hi, All!

LAMW "0.8.6.2" moving to Android API >= 30 !!!

Please, update your android sdk/platforms folder!
How to:
.open a command line terminal and go to android folder "sdk/tools/bin"
.run the command  >>sdkmanager --update
.run the command  >>sdkmanager "build-tools;30.0.2" "platforms;android-30"


Thanks to All!
Title: Re: Android Module Wizard
Post by: dseligo on April 14, 2022, 02:06:22 am
Hi, All!

LAMW "0.8.6.2" moving to Android API >= 30 !!!

Please, update your android sdk/platforms folder!
How to:
.open a command line terminal and go to android folder "sdk/tools/bin"
.run the command  >>sdkmanager --update'
.run the command  >>sdkmanager "build-tools;30.0.2" "platforms;android-30"


Thanks to All!

Great!

Thank you for your effort.
Title: Re: Android Module Wizard
Post by: WayneSherman on May 02, 2022, 04:15:54 am
For a fresh install of Lazarus/FPC/LAMW (using FPCUPdeluxe) on Linux and Windows, I am getting an error when I do the following:

1) Close Lazarus and reopen it.
2) Create a new LAMW GUI project
3) Try to place controls on the form.

For example when I try to put a jButton on the form I get an error message:  "Error moving component JButton1:JButton".  (and the jButton never shows up on the form.)

But if I save the project and re-open it, the error message is gone and it works as expected.  If I open a demo project, they also work properly.

Please see attached error message.
Title: Re: Android Module Wizard
Post by: jmpessoa on May 02, 2022, 07:12:20 pm
Recently someone reported this issue when installing Lazarus from trunc ....

Are you using trunc version?
Title: Re: Android Module Wizard
Post by: WayneSherman on May 02, 2022, 07:17:19 pm
Recently someone reported this issue when installing Lazarus from trunc ....
Are you using trunc version?

Using stable FPC and stable Lazarus.

For Linux, it is installed according to current Linux HowTo with FPCUpDeluxe:
https://forum.lazarus.freepascal.org/index.php/topic,40750.0.html

For Windows, it is installed according to current Windows HowTo with FPCUpDeluxe:
https://forum.lazarus.freepascal.org/index.php/topic,59226.0.html
TinyPortal © 2005-2018