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);