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();
}
}
}
{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.
{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.
public native int getGraphics(ByteBuffer graphicsBuffer, int w, int h);
{ 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;
const NativeMethods:array[0..0] of JNINativeMethod = (
(name:'getGraphics';
signature:'(Ljava/nio/ByteBuffer;II)I';
fnPtr:@getGraphics;)
);
At the moment I am working hard to bringThat looks delicious, I'll be waiting...
Android Controls for Lazarus by simonsayz
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
{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.
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!Hmm... does it use relative positioning or absolute or something else?
Hmm... does it use relative positioning or absolute or something else?
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
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);
procedure TAndroidModule6.DataModuleRotate(Sender: TObject; rotate: integer;
var rstRotate: integer);
begin
Self.UpdateLayout; <<<----------------- suporte building in!
end;
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
{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.
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!
warning: the original laz4android1.1-41139 is win32 and just for Android NDK-7c
I put this on readme.txt:Upon installing, I got these:
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 ...
/usr/bin/ld: cannot find -lGLESv2I 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.
/usr/bin/ld: cannot find -lGLESv1_CM
/usr/bin/ld: cannot find -ljnigraphics
/usr/bin/ld: cannot find -llog
You is using Windows or Linux?Linux
Please check my "Android Module Wizard: Configure Paths"I haven't gone that far, the problem appears when installing the .lpk to the IDE
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.
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.
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.
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.
Linux?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.
I haven't gone that far too... :D :( :-[
1. At the moment "lazandroidwizardpack.lpk" has a simple Windows dependencySimple, isn't it? The cross platform constants are in the System unit ;)
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!)Both.
What *.lpk is you trying?
About Package, Components and LCL and NDK libs(.so) dependency on laz4android1.1-41139 IDE cross compiler...
About Package, Components and LCL and NDK libs(.so) dependency on laz4android1.1-41139 IDE cross compiler...
I couldn't get the back key to work from the main (menu) form.
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
<?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>
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
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
//------------------------------------------------------------------------------
//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");
}
**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_____
// 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. libname = {$ifdef android}'libGLESv1_CM.so'
{$else ifdef linux}'libGL.so'{$endif};
this will work ?New! Support for Linux! Thanks to Leledumbo!
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
libname = {$ifdef linux}'libGL.so'{$else}'libGLESv1_CM.so'
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?
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.
Sorry, this bug was introduced after some minor change... Fixed!
{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.
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
object jButton1: jButton
Id = 2238642
PosRelativeToAnchor = [raAlignLeft] <<<-----------
object jButton1: jButton
Id = 2238642
PosRelativeToAnchor = [] <<<-----------
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
<uses-sdk android:minSdkVersion="10"/>
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:AForm := App.Forms.Stack[App.Forms.Index-1].Form;
I'm curious with App.Forms.Index, so I add: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.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?[and Lazarus by jmpessoa@hotmail.com - december 2013] <- it's not commented
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.
Open the app first, then exit by pressing back button. Then try to open the app again. You'll get blank form instead
public void appFinish () {
activity.finish();
System.exit(0); // << ----------- Fix Here!
}
Please, try this in ["Controls.java", line 4468] for all GUI Apps Demos....OK, that works. Thanks.
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
...
With the ability to add/remove the row anytime.I need to access sqlite, my app would be highly database driven.
If you're OK, please give me write access so I can push my local commits...
I want to create something like:
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
<Name><TextView><CheckBox>
...
With the ability to add/remove the row anytime.
But, that is just a first attempt.... maybe I can create something more flexible likeOne approach:
a property/component "jCustomRow"....
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.
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;
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!
....can't wait when you will publish some results!
{$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}
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;
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();
}
}
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.
....when i select menu from hardware MENU button the submenu can't dispayed....
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 ?? ()
@Leledumbo,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.
Did you recompile the IDE clean? I did and the IDE aborts the compilation (panic).
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 !!!
...........
...........
}
......
......
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"
.....
....
@Leledumbo [and All],Hmm...not yet so far, just that exception handling.
OK. Have you some new component requirement?
Thanks!
....You can run ProGuard since not all classes...
how to use toast?
public void ShowMessage(String msg){
Log.i("ShowMessage:", msg);
Toast.makeText(controls.activity, msg, Toast.LENGTH_SHORT).show();
}
Toast.makeText(controls.activity, "my message", Toast.LENGTH_SHORT).show();
procedure jForm.ShowMessage(msg: string);
begin
UpdateJNI(gApp); // << ---- "refresh" Context!
jForm_ShowMessage(Self.App.Jni.jEnv, Self.App.Jni.jThis, FjObject, msg);
end;
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;
jTextView.Text := 'İETT Otobüs Sefer Bilgisi (iettosb), İETT''nin yurt içi taşımacılığı...';
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;
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();
}
Hi All!Congratulations! How's the GUI designer progress?
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!
...How's the GUI designer progress?
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;
procedure TAndroidModule3.jListView1ClickCaptionItem(Sender: TObject;
Item: integer; caption: string);
begin
// global variable
global.SelectedHat := caption;
Close;
end;
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;
unit Global;
{$mode delphi}
interface
uses
Classes, SysUtils;
var
SelectedHat: string;
implementation
end.
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;
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;
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;
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!)
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.
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!)
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!
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...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.
Thanks in advance
android:theme="@style/AppTheme" >
@Leledumbo, you got played with new "form designer" version? ;DIs 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).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.
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.
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!
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!
"C:\adt32\eclipse\workspace"Is my "eclipse workspace" with I have set in Android Module Wizard config path dialog....
"C:\adt32\ndk7"Is my "NDK" path with I have set in Android Module Wizard config path dialog....
Ok change, but other error. Why?Adjust those paths to YOUR installation.
Error: Path "C:\adt32\eclipse\workspace\AppSqliteDemo1\libs\armeabi\" does not exist
where?I don't know, it's your computer, not mine. You should know by yourself despite the hardcoded paths in the examples.
Hi xinyiman,
Lazarus
->Project
->Project -> Option
->Path
Change this information for correct one!
"C:\adt32\ndk7"
"C:\adt32\eclipse\workspace"
Error: Path "C:\adt32\eclipse\workspace\AppSqliteDemo1\libs\armeabi\" does not exist
Hi xinyimanQuoteError: 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 ..
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
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
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
Anchor = jButton1
<property name="target" value="android-17"/>
<property name="target" value="android-17"/>
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>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17" />
<style name="AppBaseTheme" parent="android:Theme.Light">
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>
[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'.
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
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
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').
<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>
ShowMessage(IntToStr(rows.Count)) ;
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;
...continues to go wrong..
{for i:= 0 to rows.Count-1 do
begin
ShowMessage(rows.Strings[i]);
end;}
ShowMessage(IntToStr(rows.count)); // <<-----
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;
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;
jSqliteDataAccess1.Select('SELECT * FROM '+ FTableName + ';');
jSqliteDataAccess1.Select('SELECT * FROM '+ FTableName);
rowCount:= jSqliteDataAccess1.Cursor.GetRowCount;
ShowMessage('rowCount= '+ IntToStr(rowCount));
//jSqliteDataAccess1.DeleteFromTable('delete from ' + FTableName + ';'); // <<-----
Hi All! There are a update [revision] for Android Module Wizard...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.
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!
"<property name="target" value="android-14"/>"
"<property name="target" value="android-17"/>"
...after asking for Laz4Android location (I don't think it's required)...
@ Leledumbo,lazbuild is part of lazarus, not laz4android, so it should be deducible automatically.Quote...after asking for Laz4Android location (I don't think it's required)...
Yes, we need "lazbuild" to rebuild ".so" in "LATE" [IDE plugin]...
... .so itself eats 2.6 MB uncompressed ...
TAndroidModule1 = class(jForm)
jButton1: jButton;
jEditText1: jEditText;
jListView1: jListView;
jSpinner1: jSpinner;
jTextView1: jTextView;
procedure jButton1Click(Sender: TObject);
private
{private declarations}
public
{public declarations}
end;
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]:Hello guys, I want to prepare a virtual machine (linux) with everything already installed. I want to know the right steps to do2 -> Install Android sdk, anything else but the sdk is useless for development with this package
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?
..but it's realy hard to get working setup. ...
...BackgroundColor is TARGBColorBridge ... why? :o I need custom colors..
Can you help here! What about a new "Get Start!" tutorial? Help me!I can look at this.
jTextView1.BackgroundColor := $FF2C2F3E;
....
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;
import android.view.inputmethod.EditorInfo;
Source:public void setInputTypeEx(String str) {
bufStr = new String(str.toString());
this.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
...
this.setBackgroundColor(0);
this.setHint("This will be hint when edit box is empty");
...I can give you the link on the result of me work if you are interested in it....
library MyLibrary;
{$mode objfpc}{$H+}
function Add(a, b: integer): integer;
begin
Result := a + b;
end;
exports
Add name 'Java_Adder_Add';
begin
end.
package org.test.project1;
class Adder
{
public native int Add(int a, int b);
static
{
System.loadLibrary("mylibrary");
}
}
How can we use the library from question 1 (.so without source code) in a LazAndroidModule project?case A:
case A: called from java code
case B: called from pascal code
..
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;
...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 ....
a- the java code make the calls to libcontrols1.so
b- the pascal code make the calls to libcontrols1.so ...
package jmpessoa.ndktest;
public class MyLib {
static {
System.loadLibrary("MyLib");
}
public native int add(int x, int y);
public native String getHello();
}
JNIEXPORT jint JNICALL Java_jmpessoa_ndktest_MyLib_add(JNIEnv *, jobject, jint, jint);
JNIEXPORT jstring JNICALL Java_jmpessoa_ndktest_MyLib_getHello(JNIEnv *, jobject);
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;
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';
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;
package jmpessoa.ndktest;
public class MainActivity extends Activity {
//From JNI
MyLib mylib = new MyLib();
String helloFromC = mylib.getHello();
int sum = mylib.add(2,5);
...........................
}
package strange.test;
public class MyLib {
static {
System.loadLibrary("MyLib");
}
public native int add(int x, int y);
public native String getHello();
}
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.
And_Controls + iOS_Controls = XCL_ControlsIf you can create LCL backends with them too, we can have single source codebase for these platforms shared with desktop ones ;)
gApp.Finish; //gApp --> global android App --> MainActivity
Glad to help.
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?
1. The main problem ....ref. http://forum.lazarus.freepascal.org/index.php/topic,21919.msg169959.html#msg169959
...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!
A [NoGUI] JNI Android loadable module (.so)
using DataModule (NO Form Designer/Android Components Bridges)!
A [GUI] JNI Android loadable module (.so)
based on Simonsayz's templates
with Form Designer and Android Components Bridges!
....When the keyboard appears jEdittext moves above the keyboard....
jEditText1.SetImeOptions(imeFlagNoFullScreen);
procedure TAndroidModule1.jEditText1Change(Sender: TObject; txt: string;
count: integer);
begin
jEditText1.SetImeOptions(imeFlagNoFullScreen);
end;
jEditText1.SetImeOptions(imeFlagNoFullScreen);
in jForm "OnJNIPrompt" event? If not, please, test it there!Code: [Select]procedure TAndroidModule1.jEditText1Change(Sender: TObject; txt: string;
count: integer);
begin
jEditText1.SetImeOptions(imeFlagNoFullScreen);
end;
...Going to torment tablet. On the tablet is a terrible layout. :o
.....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)?
when something CAN go wrong.... Will go wrong! :D :D
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<CustomData Count="1">
<Item0 Name="LAMW" Value="GUI"/>
</CustomData>
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>
Note: to transfer file via Bluetooth,
you need to do some common user's tasks:
activate bluetooth, detect neighbors devices and pair neighbors devices....
HINT: to compile/install/reinstall a package in Laz4Android, please, open a "dummy" windows project.... you always MUST close the cross compile project!
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!QuoteHINT: to compile/install/reinstall a package in Laz4Android, please, open a "dummy" windows project.... you always MUST close the cross compile project!
Thank you!
@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 can't see anyandroidmodule from your demo folder
<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>
<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>
Note: But to simply learn from the example code you need only study "unit1.pas" and "unit1.lfm"
@m4u_hoahoctroQuote... 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....QuoteNote: But to simply learn from the example code you need only study "unit1.pas" and "unit1.lfm"
HINT: to compile/install/reinstall a package in Laz4Android, please, open a "dummy" Windows project.... you always MUST close the cross compile[Lamw] project!
ooopsThat'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).
what is this window ? (open demo ActionBartab)
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;
procedure TAndroidModule1.jButton2Click(Sender: TObject);
begin
name1:=tstringlist.create;
name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
showmessage(name1.strings[0]);
end;
ooops
what is this window ? (open demo ActionBartab)
{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.
.... humm, does my phone is too old,so it can't play this app ?
Code: [Select]procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
name1:=tstringlist.create;
name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
showmessage(name1.text);
name1.free;
end;
var name1: TStringList
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
name1: TStringList; //<<--------
begin
name1:=tstringlist.create;
name1.Add(jtextfilemanager1.LoadFromAssets('name1.txt'));
showmessage(name1.text);
name1.free;
end;
....Press build and run
Note: for old projecs [before rev. 20 - 07 April 2015], please change "controls.lpi":
after:Code: [Select]<VersionInfo>
Add this new entry:
<StringTable ProductVersion=""/>
</VersionInfo>Code: [Select]<CustomData Count="1">
<Item0 Name="LAMW" Value="GUI"/>
</CustomData>
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;
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;
...when i create new gui ,it can not load 'App.java'...Supposing you have chosen new project as "JNI Android Module [Lamw GUI]"
...result is null...I do just now a new test... and I not got this mistake too ...
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;
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;
....how can i get itemindex (number of item clicked)....
procedure TAndroidModule1.jListView1ClickCaptionItem(Sender: TObject; Item: integer; caption: string);
begin
case Item of
0: ............
1: ...........
2: ...........
end;
end;
if jListView1.IsItemChecked(1) then ....
else ......
thanks, and :-[I think you should ask bluestacks maintainer instead of us. Surely they know their product best.
I am using Bluestacks as a virtual android device,but I don't know where virtual sd card drive is, please help :-\
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;
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
jEditText1.SetFocus;
end;
procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
jEditText2.SetFocus;
end;
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!
......I posted my app in Yandex.store :D
....The form is destroyed, but not created again. If it possible, show an example code.
...how to use Android Module Wizard to run a command line which in /system/bin ?
@ rx3.fireproofQuote......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!
@greenzyzyzyQuote...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!
.... i slove the problem,it is a easy way to run command with asyncprocess unit.
@greenzyzyzyCode: [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!
I hope you will update sms reading function soon :)
...May be an error while upgrade code template with old version LAMW?
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
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
...Is there a way to get position and size of a component? Right now Left/Top/Width/Height .
...add component to form/custom dialog using code but failed
...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]
greenzyzyzy, try to update .java files.
greenzyzyzy, try to update .java files.
@ greenzyzyzyQuotegreenzyzyzy, 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!
greenzyzyzy, can you provide build log (copy from messages window)?
greenzyzyzy, can you provide build log (copy from messages window)?
...laz4android play a mp3 need what uses-permission?
jMediaPlayer1.SetDataSource('pipershut2.mp3'); //from .../assets...
jMediaPlayer1.Prepare();
jMediaPlayer1.Start();
@greenzyzyzyQuote...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!
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.
@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()
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;
@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] ...
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.
1.jpg
image2,jpg
3.jpg
4.jpg
5.jpg
...would you like to help me to have a test with my codes?
@m4u_hoahoctroQuote1.jpg
image2,jpg
3.jpg
4.jpg
5.jpg
You can see "image2,jpg" ..... fix it!
@greenzyzyzyQuote...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!
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.
@m4u_hoahoctroQuote1.jpg
image2,jpg
3.jpg
4.jpg
5.jpg
You can see "image2,jpg" ..... fix it!
@greenzyzyzyQuote...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!
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;
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;
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!
@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!
....In the latest version, the jScrollView does not work.
@ greenzyzyzy,
Lamw has native jBitmap, native jImageFileManager, native jImageView and native jAsynTask....
You can try some demos apps....
Thank you!
....I need scrolling...
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]
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;
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
jimage1: jObject;
begin
jimage:= jImageFileManager1.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirSdCard),'image1.png');
jImageView1.SetImageBitmap(jimage1);
end;
@rx3.fireproof,Quotewould 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 ....
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....
...I can't add any procedure. It shows error:foward declaraction not solved
@ m4u_hoahoctroQuote...I can't add any procedure. It shows error:foward declaraction not solved
Where ? Please, put your code here.....
@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
about error:
....Identifier not found "Java_Event_pOnAsyncEvent"
....copy old code ?
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;
@m4u_hoahoctro
QUESTION 1Quoteabout 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]
..... how to get content of a website ( then save to tstringlist )....
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;
....jmediaplayer can't open film file ?
... Have you in plan to implement https and/or OAuth protocol?
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;
Today I tested bluetooth app again, I used your code in BluetoothAppDemosQuotevar 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
Today I tested bluetooth app again, I used your code in BluetoothAppDemosQuotevar 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.
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!
@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.
... For now, I'm gonna put this on pause
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.
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
@ m4u_hoahoctro
here is a simple HttpClient and WebView demo ....
https://jmpessoa.opendrive.com/files?Ml85MDM4MzUyNV9lS2ZMTw
...Is it possible to automate the generation of a unique Id for the newly created object?
...the correct way to work with jHttpClient authentication ...
...Can you extend the jHttpClient Class implementing the UPDATE and DELETE methods?
...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?
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)
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);
}
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);
}
@jmpessoa
How to open sdcard on android emulator?, i want to create folder and add image or video from computer to it :D
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."
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.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 ?
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.
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 !!
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
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.
......
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
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);
}
public long GetLastId() {
if (this.cursor != null) {
int index = 0;
index = this.cursor.getColumnIndex("ROWID");
this.MoveToLast();
return this.GetValueAsLong(index);
}
else{
return -1;
}
}
function jSqliteCursor.GetLastId: integer;
begin
if not FInitialized then Exit;
Result:= integer(jSqliteCursor_GetLastId(FjEnv, FjObject ));
end;
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;
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()J');
@renabor
OK, java/JNI 'long' signature is "J", thenCode: [Select]_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');
change to:Code: [Select]_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()J');
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 !!
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;
}
});
----- 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;
}
....I'm trying to adapt this example http://www.codelearn.org/android-tutorial/android-listview
2. How to disable OnJNIPrompt event, when a form is reactivated trough a Backkeypressed?
1.What to use instead «gapp.BaseIndex»?
if(AndroidModule2 = nil) then
begin
gApp.CreateForm(TAndroidModule2, AndroidModule2);
AndroidModule2.PromptOnBackKey:= False;
AndroidModule2.TryBacktrackOnClose:= True;
AndroidModule2.Init(gApp);
end
else
begin
AndroidModule2.Show;
end;
if(AndroidModule3 = nil) then
begin
gApp.CreateForm(TAndroidModule3, AndroidModule3);
AndroidModule3.PromptOnBackKey:= False;
AndroidModule3.TryBacktrackOnClose:= True;
AndroidModule3.Init(gApp);
end
else
begin
AndroidModule3.Show;
end;
if(AndroidModule3 = nil) then
begin
gApp.CreateForm(TAndroidModule4, AndroidModule4);
AndroidModule4.PromptOnBackKey:= False;
AndroidModule4.TryBacktrackOnClose:= True;
AndroidModule4.Init(gApp);
end
else
begin
AndroidModule4.Show;
end;
Hello m4u_hoahoctro !
Yes! some links to test ?
form_index_0_level:=-1;
form_index_1_level:=-1;
form_index_2_level:=-1;
form_index:=-1;
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.
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;
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.
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.
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.
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.
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.
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.
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
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;
FImageBitmap:= Get_jObjGlobalRef(FImageBitmap);
Delete_jGlobalRef(FImageBitmap);
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;
procedure TAndroidModule1.jView1TouchDown(Sender: TObject; Touch: TMouch);
begin
ShowMessage('Touch: X='+ FloatToStr(Touch.Pt.X) + ' Y='+FloatToStr(Touch.Pt.Y) );
end;
procedure TAndroidModule1.jSurfaceView1TouchDown(Sender: TObject; Touch: TMouch);
begin
ShowMessage('Touch: X='+ FloatToStr(Touch.Pt.X) + ' Y='+FloatToStr(Touch.Pt.Y) );
end;
If the fontsize=0.
The visual size of the font on device for jtextview less than for the jedittext. ...
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 ?
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" ...
Quote@m4u_hoahoctroQuoteCan 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]
... Save cookie is be the key...
@LeledumboI can provide a fpweb sample that you can run as a standalone app accessible from your localhost. Give me some time.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?
For jtextview SetChangeFontSizeByComplexUnitPixel is absent....
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;
@LeledumboSorry 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.
ok!
@m4u_hoahoctro
Ok I will do some demos ....
procedure ShowCustomMessage(_layout: jObject; _gravity: integer; _lenghTimeSecond: integer); overload;
should be:
procedure ShowCustomMessage(_layout: jObject; _gravity: TGravity; _lenghTimeSecond: integer); overload;
...so in my application Caption isn't a string and I can't get ItemIndex
jListView = class(jVisualControl)
private
FOnClickItem : TOnClickCaptionItem;
.....
TOnClickCaptionItem= Procedure(Sender: TObject; itemIndex: integer; itemCaption: string) of object;
procedure TAndroidModule1.jListView1ClickItem(Sender: TObject; itemIndex: integer; itemCaption: string);
begin
end;
controls.pOnClickCaptionItem(PasObj, (int)position , alist.get((int)position).label);
controls.pOnClickCaptionItem(PasObj, (int)id , alist.get((int)id).label);
...I hope you can help me
//////////////////////
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
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)
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)
label = "";
in constructorprocedure pOnClickCaptionItem(PEnv: PJNIEnv; this: JObject; pasobj: JLong; position: JInt; caption: JString); cdecl;
begin
Java_Event_pOnClickCaptionItem(PEnv,this,TObject(pasobj),position,caption);
end;
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;
jListView = class(jVisualControl)
FOnClickItem : TOnClickCaptionItem;
private
...................
protected
procedure GenEvent_OnClickCaptionItem(Obj: TObject; index: integer; caption: string);
....................
end;
TOnClickCaptionItem= Procedure(Sender: TObject; itemIndex: integer; itemCaption: string) of object;
Procedure jListView.GenEvent_OnClickCaptionItem(Obj: TObject; index: integer; caption: string);
begin
if Assigned(FOnClickItem) then FOnClickItem(Obj,index, caption);
end;
gapp.CreateForm(tandroidmodule1,androidmodule1);
androidmodule1.Init(gapp);
androidmodule1.show;
androidmodule2.finish;
/////////////////
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
/////////////////
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;
}
how to call a webservice
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!
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)
jHttpClient1.SetAuthenticationHost('',-1);
jHttpClient1.AuthenticationMode:=autBasic;
jHttpClient1.SetAuthenticationUser('username', 'password');
jHttpClient1.AddNameValueData('name','value');
jHttpClient1.AddNameValueData('anothername','anothervalue');
jHttpClient1.PostStateful('http://yourhost');
string := jHttpClient1.Get('http://yourhost/getservice');
jHttpClient1.DeleteStateful('http://yourhost','whattodelete');
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!
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);
}
}
Eclipe/Ant project [finally] unified!Nice, less unneeded option since practically all Eclipse projects are Ant-compatible, just provide a proper build.xml.
@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"
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;
Yes, I guess it! but ... something where wrong creating a new App.
@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!
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.
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!
..When i every open options menu and closed, menu item is adding same menu item to the options menu...
@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
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);
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);
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;
}
});
jListView1.SetFab(jImageFileManager1.LoadFromResources('ic_android'));
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);
}
});
}
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)
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);
public void setFab(Bitmap imageBmp) {
ImageView imageView = new ImageView(controls.activity);
.....................
}
/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
A/libc(30743): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
... I've found that after Android 4.0 ...
@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"
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;
New info, doesn't matter where the code is, it simply doesn't work, here, a sample of how it looks:At least 2: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?
@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 ?
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
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:
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?
/usr/bin/ld: cannot find -lGLlibGL is part of your OpenGL capable graphics card driver. You need to install the respective development package.
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.
const DATA_A = 'data_a';
DATA_2 = 'data2';
s:= vja.Objects[i].Strings[DATA_A]+' - '+vja.Objects[i].Strings[DATA_2];
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?!
(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
Thank you :)/usr/bin/ld: cannot find -lGLlibGL is part of your OpenGL capable graphics card driver. You need to install the respective development package.
.
.
.
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"
*5.PANIC ? [upgrade your project [or demo] code templates!] !
* Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]
*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"/>
*
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"
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] ^
...package org.apache.http.auth does not exist
@xinyimanView attachmentQuote...package org.apache.http.auth does not exist
I think you have some problem with the java [configuration] path ...
@xinyimanView attachmentQuote...package org.apache.http.auth does not exist
I think you have some problem with the java [configuration] path ...
<?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>
<?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>
...Installed API 23 for sdk is this the problem?!
@xinyimanQuote...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!]
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?
With 21 API are able to compile correctly.
How do I configure the emulator Android?
So then release the virtual machine.
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.
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 &
@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
## 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
..that stores information of the application, even if the device shut down..
controls.lpr(1427,15) Error: Util arm-linux-androideabi-ld not found ...
arm-linux-androideabi-ld not found
Hello xinyiman!
As said by jmpessoa, the error is related toCode: [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
/home/generico/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
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
$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";
}
}
?>
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?
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 ?
Hello xinyiman!
Updated: https://github.com/jmpessoa/lazandroidmodulewizard
"jGridView" now can change Item title!
procedure UpdateItemTitle(_index: integer; _title: string);
Thank you very much :D
You can get "index" handling "onclick" event ....
Thank you!
I installed the new version of Blade ... %)
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 [...]QuoteI installed the new version of Blade ... %)
Please, put a figure/image here....
..Please fix jswitchbutton component
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?
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"
Hello Euller!Wouldn't it be better to use enum instead of integer?
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?
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".
truetom, Check the last changes, please.
Hello All!
NEW!!
Added [initial] "Android Themes" support!
ref. https://github.com/jmpessoa/lazandroidmodulewizard
Thanks to All!
android-ndk-r10c
C:/Program Files/laz4android'
screen rosolution too small. how to fit componnt with 720 x 1280 pixels or streching with all size screen?
Second question. Is there any way to save String to file which is available (visible) via usb cable and some storage folder on phone...
Is there some function which will convert unicode string to byte array or stream? This will solve problem....
. Installation is little bit painful, but once setup is finished almost everything work OK
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
jMenu1.Clear();
self.RemoveAllTabsActionBar();
jMenu1.InvalidateOptionsMenu();
public void RemoveAllTabsActionBar() {
ActionBar actionBar = this.controls.activity.getActionBar();
actionBar.removeAllTabs();
this.controls.activity.invalidateOptionsMenu();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); //API 11 renabor
}
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 )JNIAndroidProject.ini is located in lazarus configuration directory, not your app (it's global for all of your LAMW projects).
http://i.imgur.com/KBa7phs.png (http://i.imgur.com/KBa7phs.png)
Hello, I would have a couple of questions. How do I ensure that a jtextbox accept only numbers?
How do I use the JTIMER?
Are there examples?
Then I wanted to know, there is a guide that explains clearly the best methods to manage the look and feel of an application made with Android (LAMW)?
Thank you
...there is a guide that explains clearly the best methods to manage the look and feel of an application made with Android (LAMW)?
1. Configure Paths:
Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" --> "Path Settings ..."
-Path to Java JDK
ex. C:\Program Files (x86)\Java\jdk1.7.0_21 {java win32}
-Path to Android SDK
ex. C:\adt32\sdk
-Select Ndk version: [ex 10e]
-Path to Ndk
ex. C:\adt32\ndk10e
-Path to Java Resources [Simonsayz's templates "*.java" and others: *.xml, default Icons, etc...
ex. C:\Laz4Android\components\LazAndroidWizard\java
', referenced from method org.lamw.lamwguiproject1.Controls.jGLSurfaceView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 188 (Lorg/lamw/lamwguiproject1/jGLSurfaceView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jGridView', referenced from method org.lamw.lamwguiproject1.Controls.jGridView_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 189 (Lorg/lamw/lamwguiproject1/jGridView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jHorizontalScrollView', referenced from method org.lamw.lamwguiproject1.Controls.jHorizontalScrollView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 190 (Lorg/lamw/lamwguiproject1/jHorizontalScrollView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jHttpClient', referenced from method org.lamw.lamwguiproject1.Controls.jHttpClient_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 191 (Lorg/lamw/lamwguiproject1/jHttpClient;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jImageBtn', referenced from method org.lamw.lamwguiproject1.Controls.jImageBtn_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 192 (Lorg/lamw/lamwguiproject1/jImageBtn;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jImageFileManager', referenced from method org.lamw.lamwguiproject1.Controls.jImageFileManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 193 (Lorg/lamw/lamwguiproject1/jImageFileManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jIntentManager', referenced from method org.lamw.lamwguiproject1.Controls.jIntentManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 196 (Lorg/lamw/lamwguiproject1/jIntentManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jLocation', referenced from method org.lamw.lamwguiproject1.Controls.jLocation_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 202 (Lorg/lamw/lamwguiproject1/jLocation;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jMediaPlayer', referenced from method org.lamw.lamwguiproject1.Controls.jMediaPlayer_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 203 (Lorg/lamw/lamwguiproject1/jMediaPlayer;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jMenu', referenced from method org.lamw.lamwguiproject1.Controls.jMenu_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 204 (Lorg/lamw/lamwguiproject1/jMenu;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jMyHello', referenced from method org.lamw.lamwguiproject1.Controls.jMyHello_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 205 (Lorg/lamw/lamwguiproject1/jMyHello;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jNotificationManager', referenced from method org.lamw.lamwguiproject1.Controls.jNotificationManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 206 (Lorg/lamw/lamwguiproject1/jNotificationManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jPanel', referenced from method org.lamw.lamwguiproject1.Controls.jPanel_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 207 (Lorg/lamw/lamwguiproject1/jPanel;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jPreferences', referenced from method org.lamw.lamwguiproject1.Controls.jPreferences_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 208 (Lorg/lamw/lamwguiproject1/jPreferences;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jRatingBar', referenced from method org.lamw.lamwguiproject1.Controls.jRatingBar_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 212 (Lorg/lamw/lamwguiproject1/jRatingBar;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSeekBar', referenced from method org.lamw.lamwguiproject1.Controls.jSeekBar_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 214 (Lorg/lamw/lamwguiproject1/jSeekBar;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSensorManager', referenced from method org.lamw.lamwguiproject1.Controls.jSensorManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 215 (Lorg/lamw/lamwguiproject1/jSensorManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jShareFile', referenced from method org.lamw.lamwguiproject1.Controls.jShareFile_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 216 (Lorg/lamw/lamwguiproject1/jShareFile;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jShellCommand', referenced from method org.lamw.lamwguiproject1.Controls.jShellCommand_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 217 (Lorg/lamw/lamwguiproject1/jShellCommand;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSpinner', referenced from method org.lamw.lamwguiproject1.Controls.jSpinner_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 218 (Lorg/lamw/lamwguiproject1/jSpinner;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSqliteCursor', referenced from method org.lamw.lamwguiproject1.Controls.jSqliteCursor_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 219 (Lorg/lamw/lamwguiproject1/jSqliteCursor;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSqliteDataAccess', referenced from method org.lamw.lamwguiproject1.Controls.jSqliteDataAccess_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 220 (Lorg/lamw/lamwguiproject1/jSqliteDataAccess;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSurfaceView', referenced from method org.lamw.lamwguiproject1.Controls.jSurfaceView_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 221 (Lorg/lamw/lamwguiproject1/jSurfaceView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jSwitchButton', referenced from method org.lamw.lamwguiproject1.Controls.jSwitchButton_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 222 (Lorg/lamw/lamwguiproject1/jSwitchButton;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jTCPSocketClient', referenced from method org.lamw.lamwguiproject1.Controls.jTCPSocketClient_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 223 (Lorg/lamw/lamwguiproject1/jTCPSocketClient;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jTextFileManager', referenced from method org.lamw.lamwguiproject1.Controls.jTextFileManager_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 224 (Lorg/lamw/lamwguiproject1/jTextFileManager;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jTimePickerDialog', referenced from method org.lamw.lamwguiproject1.Controls.jTimePickerDialog_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 227 (Lorg/lamw/lamwguiproject1/jTimePickerDialog;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jToggleButton', referenced from method org.lamw.lamwguiproject1.Controls.jToggleButton_jCreate
W/dalvikvm( 7628): VFY: unable to resolve new-instance 230 (Lorg/lamw/lamwguiproject1/jToggleButton;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jViewFlipper', referenced from method org.lamw.lamwguiproject1.Controls.jViewFlipper_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 232 (Lorg/lamw/lamwguiproject1/jViewFlipper;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jView', referenced from method org.lamw.lamwguiproject1.Controls.jView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 231 (Lorg/lamw/lamwguiproject1/jView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm( 7628): Could not find class 'org.lamw.lamwguiproject1.jWebView', referenced from method org.lamw.lamwguiproject1.Controls.jWebView_Create
W/dalvikvm( 7628): VFY: unable to resolve new-instance 233 (Lorg/lamw/lamwguiproject1/jWebView;) in Lorg/lamw/lamwguiproject1/Controls;
D/dalvikvm( 7628): VFY: replacing opcode 0x22 at 0x0000
D/dalvikvm( 7628): DexOpt: unable to opt direct call 0x0249 at 0x02 in Lorg/lamw/lamwguiproject1/Controls;.jActionBarTab_jCreate
D/dalvikvm( 7628): DexOpt: unable to opt direct call 0x024a at 0x02 in
.
.
.
.
.
[NewProject]
PathToNdkPlataforms=C:\Develop\android\android-ndk-r10e
PathToJavaTemplates=C:\Develop\lazandroidmodulewizard-master\java
PathToJavaJDK=C:\Program Files (x86)\Java\jdk1.8.0_65
PathToAndroidNDK=C:\Develop\android\android-ndk-r10e
PathToAndroidSDK=C:\Develop\android\android-sdk-windows
PathToAntBin=C:\Develop\apache-ant-1.9.6-bin\apache-ant-1.9.6\bin
NDK=3
PrebuildOSYS=windows
PathToWorkspace=D:\programming\laz4android
FullProjectName=D:\programming\laz4android\LamwGUIProject1
InstructionSet=0
FPUSet=0
ProjectModel=1
AntPackageName=org.lamw
AndroidPlatform=0
MinApi=2
TargetApi=0
AntBuildMode=debug
MainActivity=App
SupportV4=no
I created an apk file using Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run"
It did not install....
1. just a reminder: your device was prepared for "debug/development" mode?In developer options I have USB debugging="on". Is this what you mean?
2. You do "build" before "[Lamw] Build Apk and Run" ?Yes.
...I do not mind if the APK is automatically installed..
1. A first problem.... you do a small and deadly/fatal modification . Please, unchecked the "the pass option to linker with -k..." and clear the Edit below... Now you will get a correct ".so" [~ 575 k]
2. Check your "...\LamwGUIProject1\bin\classes\org\lamw\lamwguiproject1" folder ... the correct is 136 files
...I have removed the pass linker with -k box, but it still will not run.
I have only 41 files. How do I repair this?
... because laztoapk depends on laz4android.
Try HAndle OnEnter Event [go, done, next, etc]
procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
jEditText1.SetImeOptions(imeActionDone);
end;
And you can try: [from demo "AppEditTextDemo1"]
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
//jEditText1.DispatchOnChangeEvent(False); //the trick! stop event [improve performace]!
//jEditText1.DispatchOnChangedEvent(False); //the trick! stop event [improve performace]!
jEditText1.SetImeOptions(imeFlagNoFullScreen);
//IMEs will never go into full screen mode,
//and always leave some space to display the application UI
jTextView1.TextTypeFace:= tfBold;
jTextView1.CustomColor:= $FF2C2F3E;
jTextView1.FontColor:= colbrCustom;
end;
.. I click the button btn_calcola.The keyboard that opened when I entered the Txt_Sviluppo remains open. I want to close. How can I do?
And is there a way to make text inside jEditText becomes selected on certain event.
NEW! Added jEditText methods:
SetSelectAllOnFocus // <<---@Mladen suggestion
SelectAll // <<---@Mladen suggestion
There is "OnEnter" event to handle: go, done, next, ... keys
procedure TAndroidModule1.jEditText1Enter(Sender: TObject);
begin
TurnOnScanner;
end;
How can I disable screen rotation on Android device? (In programming with LAMW)
2-How can set alignment for text controls like jEdit to right? For right to left language like Hebrew and Arabic?
Hello Mladen!
Please, try:
jDialogProgress1.SetCancelable(False); jDialogProgress1.Show();
Cells.Left := i * (Cells[i, j].Height + Space) - 20; // It's work but wrong
Cells.Top := j * (Cells[i, j].Width + Space) - 20; // It's work but wrong
Cells.Top := i * (Cells[i, j].Height + Space) - 20; // It's work but wrong
Cells.Left := j * (Cells[i, j].Width + Space) - 20; // It's work but wrong
Hello Mladen!I tried jListView1.FontFace:=FFMonospace;
Sorry....
I make a minor change to try fix jListView1.FontFace
ref. https://github.com/jmpessoa/lazandroidmodulewizard
[changed]
"Controls.java"
"Laz_And_Controls.pas"
NOTE: If you have put [initial] items in design time,
then you need set jListView1.FontFace in design time, too.
Did you mean this one?No, the one under Eclipse folder. You can make it an Ant project simply by providing build.xml that you can copy from the Ant demos project and modify the values inside accordingly.
.../Android/lazandroidmodulewizard.git/trunk/demos/Ant/AppAntDemo1
I can build apk and run on my Intel-based Android phone (although the configuration is Android-arm).Intel based Android devices usually have libhoudini installed. It's an ARM compatibility layer so Intel based devices can still install and run many applications from play store which might be compiled only for ARM.
/usr/bin/arm-linux-androideabi-ld: cannot find -ljnigraphics
/usr/bin/arm-linux-androideabi-ld: cannot find -lGLESv1_CM
/usr/bin/arm-linux-androideabi-ld: cannot find -lGLESv2
/usr/bin/arm-linux-androideabi-ld: cannot find -lc
/usr/bin/arm-linux-androideabi-ld: cannot find -lc
/home/handoko/Android/lazandroidmodulewizard.git/trunk/demos/Eclipse/AppDemo1/jni/controls.lpr(1223,15) Error: (9013) Error while linking
/home/handoko/Android/lazandroidmodulewizard.git/trunk/demos/Eclipse/AppDemo1/jni/controls.lpr(1223,15) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode
But I have problem compiling the the AppAntDemo1. When I tried to compile it, I get this message:Modify path related project settings according to your installation, those libraries should be in $(your android ndk folder)/platforms/android-$(your target api)/arch-arm/usr/lib/.
Can anybody tell me, is there a way we can refresh the files generated by LAMW but keep the 'pure' Lazarus code unchanged?
...because I still have no luck building my Lazaurs to cross compile to Android-i386.
FPC Source:
/home/handoko/Android/fpc
Path to Android NDK:
/home/handoko/Android/android-ndk-r11c
Path to FPC "make.exe":
/usr/bin
Architecture:
x86
make[2]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2869: recipe for target 'build-stamp.i386-android' failed
make[1]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2935: recipe for target 'crossall' failed
Panic: tool stopped with exit code 512. Use context menu to get more information.
cd /
sudo find -name make
./home/handoko/Android/android-ndk-r11c/prebuilt/linux-x86_64/bin/make
./usr/bin/make
./usr/share/bash-completion/completions/make
./usr/share/doc/make
./home/handoko/Android/lazarus
./usr/share/lazarus/1.5.49563
Where is your fpc installed?
cd /
sudo find -name fpc
./home/handoko/Android/fpc
./home/handoko/Android/fpc/utils/javapp/src/fpc
./usr/bin/fpc
./usr/local/lib/fpc
./usr/share/doc/fpc
./usr/share/fpcsrc/3.1.1/utils/javapp/src/fpc
./usr/lib/fpc
./usr/bin/fpc
FPC Source:
/home/handoko/Android/fpc
Path to Android NDK:
/home/handoko/Android/android-ndk-r11c
Path to FPC "make.exe":
/usr/bin
Architecture:
x86
make[2]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2869: recipe for target 'build-stamp.i386-android' failed
make[1]: Leaving directory '/home/handoko/Android/fpc'
Makefile:2935: recipe for target 'crossall' failed
Panic: tool stopped with exit code 512. Use context menu to get more information.
Good day!
months earlier...I was able to screw "Android Module Wizard" in which Typhone (CodeTyphone) with the replacement of the dependencies two packages! (IDEintf, SynEdit) but today when I try to install from scratch there are incompatible types! (((
When you install lazandroidwizardpack.lpk
log(lamwdesigner.pas(668,58) Error: Incompatible type for arg no. 1: Got "<procedure variable type of procedure(TObject;ShortString) of object;StdCall>", expected "<procedure variable type of procedure(TObject) of object;StdCall>")
Can what is the correct worth in lamwdesigner.pas???
Just remove the second parameter of OnDesignerModified (completely remove {$if ..}...{$endif})thank you! worked...
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch(keyCode) {
.......................................
.......................
//default: controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode));
}
.......................
}
...as implemented by the interaction of several forms in this package?
Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]
Hi All!
There is an updated LAMW revision!!
Version 0.6 - rev. 42 - 10 May 2016 -
UPDATE! AppMenuDemo // <<--- thanks to Freris!
FIXED! OnKyDown [App.java] // <<--- thanks to Freris!
Please,
Upgrade yours projects code templates:QuoteLazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]
I was wandering is there a way to get Device Model name ....
QuoteI was wandering is there a way to get Device Model name ....
[SOLVED!]
Version 0.6 - rev. 43 - 13 May 2016 -
NEW! jForm methods:
GetDeviceModel,
GetDeviceManufacturer // <<--- thanks to Mladen
NEW! AppTFPNoGUIGraphicsBridgeDemo8 [scan pixels]// <<--- thanks to Prof. Welligton Pinheiro Santos
image ref. https://od.lk/f/Ml8xMTgzOTA0Nzdf
Thanks to All!
...JNI DETECTED ERROR IN APPLICATION:
JNI CallIntMethod called with pending exception 'java.lang.NoSuchMethodError' thrown in
void com.example.appmenudemo.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout)...
How can i set flag FLAG_KEEP_SCREEN_ON for disable sreen off?
mayby need some rights in AndroidManifest.xml ?
E:\FreePascal\4Android\projects\TestScreenMode\src\example\com\testscreenmode\Controls.java:169: error: cannot find symbol
import android.media.MediaPlayer.OnTimedTextListener; // <<< -------------------------
android:screenOrientation="portrait"
<activity android:name="org.lazarus.rx3android.App" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|screenSize|screenLayout|fontScale"
...The "ant/bin" path is not saved in the path settings.
(x) Check for disk file changes via content rather than timestamp
Now, there is a little fix [lamwdesigner.pas], to avoid frequent "Reload fromHello @jmpessoa!
disk" when the project is re-open...
We need check this option when the dialog prompt:Quote(x) Check for disk file changes via content rather than timestamp
NOTE: as always after the update, we need to re-install the package
[lazandroidwizardpack.lpk]
How can I maintain my copy of Controls.java instead of having it everytime overwrite?
Hello Renabor [welcome, again! :D :D]!
No Problem. I will open this possibility....
but, if appropriate you can also update the github... [ok,
there is a new [and smart] code architecture!]
Is it the name that mentioned several times in the documentation and the one who wrote the how to install tutorial? Wow, it's great if he back and join the development. :D
@renaborQuoteHow can I maintain my copy of Controls.java instead of having it everytime overwrite?
Please, first get update from github and then
go to "JNIAndroidProject.ini" in folder "lazarus/config" and
add this line:"f" to "false", any other value will be "true".
CanUpdateJavaTemplate=f
NOTE: this will break update to all ".java"...
[but, "old" projects before LAMW 0.7 will be update!]
Error reading CheckBox1.OnClick: Invalid value for property
I/ActivityManager( 1486): Start proc com.suevoz.borsa for activity com.suevoz.borsa/.App: pid=2185 uid=10053 gids={50053, 9997, 3003, 1028, 1015} abi=x86 W/ActivityThread( 2185): Application com.suevoz.borsa can be debugged on port 8100... I/Zygote ( 1145): Process 2185 exited cleanly (217) W/libprocessgroup( 1486): failed to open /acct/uid_10053/pid_2185/cgroup.procs: No such file or directory I/ActivityManager( 1486): Process com.suevoz.borsa (pid 2185) has died E/libprocessgroup( 2203): failed to make and chown /acct/uid_10053: Read-only file system W/Zygote ( 2203): createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT? I/art ( 2203): Not late-enabling -Xcheck:jni (already on) I/ActivityManager( 1486): Start proc com.suevoz.borsa for activity com.suevoz.borsa/.App: pid=2203 uid=10053 gids={50053, 9997, 3003, 1028, 1015} abi=x86 W/ActivityThread( 2203): Application com.suevoz.borsa can be debugged on port 8100... W/libprocessgroup( 1486): failed to open /acct/uid_10053/pid_2203/cgroup.procs: No such file or directory I/ActivityManager( 1486): Process com.suevoz.borsa (pid 2203) has died I/Zygote ( 1145): Process 2203 exited cleanly (217) E/libprocessgroup( 2219): failed to make and chown /acct/uid_10053: Read-only file system W/Zygote ( 2219): createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT? I/ActivityManager( 1486): Start proc com.suevoz.borsa for activity com.suevoz.borsa/.App: pid=2219 uid=10053 gids={50053, 9997, 3003, 1028, 1015} abi=x86 I/art ( 2219): Not late-enabling -Xcheck:jni (already on) W/ActivityThread( 2219): Application com.suevoz.borsa can be debugged on port 8100... W/libprocessgroup( 1486): failed to open /acct/uid_10053/pid_2219/cgroup.procs: No such file or directory I/ActivityManager( 1486): Process com.suevoz.borsa (pid 2219) has died W/ActivityManager( 1486): Force removing ActivityRecord{206ba514 u0 com.suevoz.borsa/.App t26}: app died, no saved state I/Zygote ( 1145): Process 2219 exited cleanly (217) W/WindowManager( 1486): Failed looking up window W/WindowManager( 1486): java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@2e0c19f1 does not exist W/WindowManager( 1486): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8413) W/WindowManager( 1486): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8404) W/WindowManager( 1486): at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2558) W/WindowManager( 1486): at com.android.server.wm.Session.remove(Session.java:186) W/WindowManager( 1486): at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2920) W/WindowManager( 1486): at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5390) W/WindowManager( 1486): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3223) W/WindowManager( 1486): at android.os.Handler.dispatchMessage(Handler.java:102) W/WindowManager( 1486): at android.os.Looper.loop(Looper.java:135) W/WindowManager( 1486): at android.os.HandlerThread.run(HandlerThread.java:61) W/WindowManager( 1486): at com.android.server.ServiceThread.run(ServiceThread.java:46) W/InputMethodManagerService( 1486): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@fb7642d attribute=null, token = android.os.BinderProxy@64ce490 D/TaskPersister( 1486): removeObsoleteFile: deleting file=26_task.xml
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpHalfOfParent
ScrollSize = 2000
PosRelativeToParent = [rpCenterInParent]
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpSevenEighthOfParent
// procedure OnDesignerModified(Sender: TObject{$If lcl_fullversion>1060004}; {%H-}PropName: ShortString{$ENDIF});
procedure OnDesignerModified(Sender: TObject);
and line 1009//procedure TAndroidWidgetMediator.OnDesignerModified(Sender: TObject{$If lcl_fullversion>1060004}; {%H-}PropName: ShortString{$ENDIF});
procedure TAndroidWidgetMediator.OnDesignerModified(Sender: TObject);
Error: Access violationhttp://imgur.com/a/dMA0D (http://imgur.com/a/dMA0D)
@m4u:
The choice depends on how the cross-compiler was built ...
for Laz4Android "armv6" and "armv7 + soft" are good!
About "Access violation" I will do some investigation...
until then, please, update and re-install the 03 LAMW packages...
Hi jmpessoa
I am using below components:
java 8 update 101 64 bits
java sdk 8 update 101 32 bits
newest version of lamw
ndk r10e
ant 1.9.7
But when i chose Project > New project and create new one, This alert always appear and i dont know how to fix itQuoteError: Access violationhttp://imgur.com/a/dMA0D (http://imgur.com/a/dMA0D)
please help. thanks much :) :)
And in dialog creating new project I see 2 options are armv7 + soft armv7 +Fv3
So which one I should choose , and what are differences ?
Thanks :) :)
If you try to put jAutoTextView on form you will get access violation...
This is Laz4Andorid.Cannot reproduce.
SVN 51630
does Android Module Wizard can use the android api like below?tfpandroidbridge_pack package has and_jni unit which similarly wraps jni as jni unit does. Most of the unit contents are the same, only jmpessoa add little additions, everything else should remain the same. javaEnvRef is defined in customdrawnint unit, so you can't use that if you use LAMW. LAWM equivalent of it is AndroidWidget.gApp.Jni.jEnv.
FindClass:function(Env:PJNIEnv;const Name:pchar):JClass;{$ifdef mswindows}stdcall;{$else}cdecl;{$endif}
does lamw can use java api directly which just like use windows api now?
.A specification/protocol for calling 'native' code from Java and Java code from native applications ('Invocation API');
.An interface that allows Java to interact with code written in another language: The Java code can invoke native methods;
.An interface that allows code written in another language to interact with Java : The native code can instantiate Java objects and invoke methods;
.JNI is about "Programming for the Java Virtual Machine";
.JNI is used to interact with "native" code produced by system-level language like C/C++ and Pascal/Object Pascal!
E/art: dlopen("/data/app/com.suevoz.borsa-1/lib/arm/libcontrols.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "U_$CONTROLS_$$_MOUSE" referenced by "libcontrols.so"...
E/JNI_Load_LibControls: exception
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "U_$CONTROLS_$$_MOUSE" referenced by "libcontrols.so"...
Hi, All!
Inspired by @tk's works...
Added LAMW support to build custom library!
NEW: LAMW IDE Tools "Import C Stuff"
NEW: LAMW Console App chebox "Library"
[Linux: need add "ht2pas" to folder "ide_tools"]
ref. https://github.com/jmpessoa/lazandroidmodulewizard
Thanks to All!
Found! h2pas (not ht2pas) in fpc/bin !
QuoteFound! h2pas (not ht2pas) in fpc/bin !
Yes! Please, send me your linux "h2pas" [32 bits] or
put it in LAMW github [folder "ide_tools"].
Hi All!
There is an updated LAMW revision!
ref https://github.com/jmpessoa/lazandroidmodulewizard
Version 0.7.11 - 17 - Feb - 2017
NEW! jWindowManager component
NEW! demo AppWindowManagerDemo1
[floating and draggable View!]
IMPROVED!
jForm: news methods:
Minimize
Restart
jButton: news methods
SetCompoundDrawables
SetRoundCorner
SetRadiusRoundCorner
jTextView: news methods
SetCompoundDrawables
SetRoundCorner
SetRadiusRoundCorner
jRadioGroup: news methods
SetRoundCorner
SetRadiusRoundCorner
jPanel:: news methods
SetRoundCorner
SetRadiusRoundCorner
jImageView: news methods
SetRoundCorner
SetRadiusRoundCorner
jEditText: news method
SetCompoundDrawables
jCheckBox: news method
SetCompoundDrawables
jRadioButton: news method
SetCompoundDrawables
Thanks to All!
PS.
Hi @majid.ebru the "AppLocationDemo1" was updated!
controls.lpr(564,1) Error: Wrong number of parameters specified for call to "Java_Event_pOnDraw"
Yes, OnDraw signature changed [lost the parameter jCanvas]! [sorry....]
Please, update your "Controls.native" and your
event handler code.... [now we need just set the property "canvas"
in design time]
java.lang.UnsatisfiedLinkError: No implementation found for int com.suevoz.borsa.Controls.pAppOnScreenStyle() (tried Java_com_suevoz_borsa_Controls_pAppOnScreenStyle and Java_com_suevoz_borsa_Controls_pAppOnScreenStyle__)
at com.suevoz.borsa.Controls.pAppOnScreenStyle(Native Method)
at com.suevoz.borsa.Controls.jAppOnScreenStyle(Controls.java:1258)
at com.suevoz.borsa.App.onCreate(App.java:63)
Maybe the error can be in another [start] place....
Have you some jImageList component? If yes, put a new [dummy] jImageList in form... save all.... now delete the dummy....
So your project has been updated! [jImageList now need a "jImageList.java" template....]
You do not need handle the ".create" or ".native" for the components.... the form wizard will take care of this...
What about create a new [test] project .... So you will understand the
new "smartdesigner" ..... and where is handled this stuff...
CanUpdateJavaTemplate = "True".
1. "Controls.java" + "Controls.native" + "jCommons.java"are default for all initial project [like an "empty" form]
2. Every [almost] component has a ".java" and a ".create" and [optional] a ".native" and [optional] etc ...
3. When you drag&drop a jComponent, over the form, the "jComponent.java" is inserted in your project ".../scr/...." and the component ".create" and ".native" are added at the end of "Controls.java"
4.The "smartdesigner" use these information to generate a custom ".lpr" whenever a "save all" occur...
java.lang.UnsatisfiedLinkError: No implementation found for int com.suevoz.borsa.Controls.pAppOnScreenStyle() (tried Java_com_suevoz_borsa_Controls_pAppOnScreenStyle and Java_com_suevoz_borsa_Controls_pAppOnScreenStyle__)
{ Class: com_suevoz_borsa_Controls
Method: pAppOnScreenStyle
Signature: ()I }
function pAppOnScreenStyle(PEnv: PJNIEnv; this: JObject): JInt; cdecl;
begin
Result := Java_Event_pAppOnScreenStyle(PEnv, this);
end;
...so can my app be run on newer version of android ?
Hi m4u!
We have only a screen, so we need set the form2 background
to some color .... [not default/transparent]
NOTE: androidmodule1.Finish not is recommendad.
About admob banner:
Good suggestion!
I will try some implementation!
Thank you!
http://www.pacifier.com/~mmead/jni/delphi/JEDI/DOCS/delphi-jni-1.html
Does running program allocate so much RAM, that Android memory management can start to automatically kill some processes?
Look at this commit for LAMW:
https://github.com/jmpessoa/lazandroidmodulewizard/commit/53f4605c6f59176eb6176bec78158c2b6ebc2a6d
You could try to apply the changes if this commit .
Or you could use fpcupdeluxe to install all brand new and updated.
Hi jmpessoa, something made me wonder.
(uses fpjson)
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
jData : TJSONData;
jObject : TJSONObject;
jArray : TJSONArray;
s : string;
begin
// create from string
jData := GetJSON('{"Fld1" : "Hello", "Fld2" : 42, "Colors" : ["Red", "Green", "Blue"]}'); // Crashed!!!
--
Hello!
Hello, Trevor!
Can you put here some "draft" picture?
OK.Thanks a lot! :thumbsup:
Try:
jListView1.Add(Text1|Text2|Text3);
and you can configure this properties:
TextAlign
TextDecorated
TextSizeDecorated
class = class(jVisualControl)
but I was not able to use the packages as my android-26 config was not recognized in the new project form.
Building APK (Gradle)... : Exit code 256, Errors: 2
Panic: xfce4-terminal: Opção desconhecida "clean"
Panic: tool stopped with exit code 256. Use context menu to get more information.
Exception, Errors: 1
Fatal: [Exception] Failed: Cannot build APK!
I have questions about jTCPSocketClient component.
Does using old android sdk manager ( like r24/r25 ) affect to created app ?
Mybe, "D:\"
Hi m4u!
Use "Ctrl+C" to copy the [complete] message from dialog...
[there is some error when converting "the demo" path to your system...]
[Window Title]
Confirmation
[Content]
Path "D:\ndk_r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.9.x\" does not exist.
Change it to "D:\ndk_r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9.x\"?
[Yes] [Cancel] [Yes to All]
Hi m4u!
The wizard is trying fix your system path...
What happens if you choose [YES]?
Hi m4u!
Go to folder "Lazarus\config"
and open the file: "JNIAndroidProject.ini"
try change the line:
PrebuildOSYS=windows
to:
PrebuildOSYS=windows-x86_64
About your example apps crashes when starts ( projects dont use compat theme or relatives ), do you have somefix ? :)
And is there some way to implement Admob into my app ?
QuoteAbout your example apps crashes when starts ( projects dont use compat theme or relatives ), do you have somefix ? :)
What example?
I/dalvikvm(21351): java.lang.NoSuchMethodError: no method with name='jTimer_Create' signature='(J)Ljava/lang/Object;' in class Lorg/lamw/myproject/Controls;
For Android 6 and higher ....
use exceptions in code....
Hello,Follow this guide (https://medium.com/mindorks/upload-your-first-android-app-on-play-store-step-by-step-ee0de9123ac0). Note: prepare your credit card.
How do I publish an apk in google play?
What´s ANT and GRADLE?
NEW! Added support to App "Runtime Permission" [Required by "target" Api >= 23]Very important feature on new Androids ! Thanks very much !!
I would like to upload an image file to my http server using httpclient post, Can you help me.
jHttpClient looks like doesn't support file upload, please can you provide me with an example code to upload file or image from the android mobile to http server
I'm using the jTCPSocketClient component in an android project and need to send a 1024 bytes sequence, but it can not send bytes, only string by the jTCPSocketClient.SendMessage command.
It would have a way to send bytes instead of text.
Hi, CC!
1) For not "AppCompat" themes you can use/target any recent API .... [warning: the R24.4.1 is the last that support "ant" builder] ... Recommended: target 21 or 22 [not run permission is required !!!]
2) Yes, R24.4.1 [or any...] is not "complete" out of box...
[from "LAMW getting started.txt"]
1)after unpacked [R24.4.1 or any...], open a terminal and go to "sdk/tools" folder
2)run cmd "android sdk" to open a GUI "SDK Manager"
3)check "Android SDK Tools"
4)check "Android SDK Platform-Tools"
5)check "Android SDK Build-Tools 25.0.3" [need for "gradle" builder]
5.1)check "Android SDK Build-Tools 26.0.2" [need for "gradle" builder]
6)go to "Android 7.1.1 (API 25)" and check "SDK Platform" [need for "AppCompat" themes and "gradle" builder]
7)go to "Extras" and check:
"Android Support Repository"
"Android Support Library"
"Google USB Drive"
3) For "AppCompat" themes the only "recommended" for LAMW:
"Android SDK Build-Tools 25.0.3" [need by old "gradle" plugin]
"Android SDK Build-Tools 26.0.2" [need by 3.0.1 "gradle" plugin ...]
"Android 7.1.1 (API 25)"
"Extras": "Android Support Repository"
"Android Support Library"
Hello,Not sure "Android emulators" window is a correct place for such button. This dialog is intended to start AVDs. If some AVD is already started (or real devices is connected via USB), this dialog won't be shown.
I have a wish for the next version.
Could you place a button like this (see attachment).
It would open the explorer at the location of the .apk-file.
As I found here https://www.askingbox.com/question/lazarus-open-folder-in-explorer (https://www.askingbox.com/question/lazarus-open-folder-in-explorer) it should be easy.
OpenDocument('C:\Example');
Thank you.
Hi abssistemas!
Attached is a new java template .....
Put this [unzipded!] "jTCPSocketClient .java" file in the folder "..... \java\lamwdesigner" of the LAMW framework ...
re-open your project and make a new build .... etc ....
Please, test the "SendBytes" and also the "SendMessage"
Thank you!!!
I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.
@abssistemas
[jTCPSocketClient componet]QuoteI tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.
Thank you!!!
Would you be able to modify the component to receive bytes instead of string?
QuoteWould you be able to modify the component to receive bytes instead of string?
Done!!!
procedure TAndroidModuleTCP.jButton1Click(Sender: TObject); begin //NEW!!! Prepare to "Send" and "Receive" bytes jTCPSocketClient1.SetDataTransferMode(dtmByte); jTCPSocketClient1.ConnectAsync('192.168.0.105', 54321); end;
//Handle Bytes Received .... procedure TAndroidModuleTCP.jTCPSocketClient1BytesReceived(Sender: TObject; var bytesReceived: TDynArrayOfJByte); var i, count: integer; begin count:= Length(bytesReceived); for i:= 0 to count-1 do begin ShowMessage(IntToStr(bytesReceived[i])) end; end;
Please, test it!!
Thank you!
Sorry... Fixed here!
The jTCPSocketClient component does not have the TOnBytesReceived event on it,
i need read all sms saved.....
QuoteThe jTCPSocketClient component does not have the TOnBytesReceived event on it,
You need to upgrade the LAMW from github!!
this event was added 6 days ago!
added here:
"tcpsocketclient.pas"
"laz_and_controls_events.pas"
With the lamw update o jTCPSocketClient worked perfectly, congratulations.
I'm having a new problem with the jActionBarTab component.
It is not working on android oreo 8.0, closes the application. In sdk target 22 it works, but 26 or 27 does not.
If I run on android 7 or smaller runs smoothly.
Thank you for your effort and dedication.
With the lamw update o jTCPSocketClient worked perfectly, congratulations.
I'm having a new problem with the jActionBarTab component.
It is not working on android oreo 8.0, closes the application. In sdk target 22 it works, but 26 or 27 does not.
If I run on android 7 or smaller runs smoothly.
Thank you for your effort and dedication.
Solved the problem with the jActionBarTab component using the target sdk 24 or 25.
What do I do to run the jActionBarTab component on sdk 26 since google play does not support sdk versions smaller than 26?
@jmpessoaThe code is 2 years old. I believe last year google maps started to lose its free (as in no API key needed) service. Today even your free calls require an API key, with limited number of calls per day (not really remember how many, probably 1000). The code definitely needs an update.
Today i built a location app, it seems be the code:
url:=jLocation1.GetGoogleMapsUrl(lat,lng); jWebview1.Navigation(url);
cant be used anymore. Google page shows that "You must use an API key to Google Maps Platform". :) :)
And I realize that jWebview hasnt scroll :o :o ?
About "jLocation" component and "AppLocationDemo1":
Fixed and updated!
Please, set the new property "GoogleMapsApiKey"
Thanks!
how to create a jTCPSocketClient component at runtime?
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
end;
How to place checkbox on jsRecyclerView...
what do i miss? why can't I display AndroidModule2 using this code?
Quotewhat do i miss? why can't I display AndroidModule2 using this code?
Please, put your project in some "online-drive". I will try help.....
I did not find an example of a login page in the LAMW demo folder....
I want to remove Titlebar...
EDITED: Fixed "Project Options" --> "LAMW..." --> "Application" theme
Please, update LAMW from github...
Thank you!
Noted.
No. That is a gradle [process] report....
What this "error" does mean? [Gradle, won't be able to install it, because it depends on "accept license" event...]
So, you need [manually] install the required sdk/platform "android-28" [and sdk/built-tools"28.0.3"].
Just execute the GUI "SDK Manager" (aka "sdk/tool/android.bat")
I think I should revert to previous LAMW....
I do it already, but all of my projects still stopped working. I even modifying old build.gradle file, because it won't build anymore.QuoteI think I should revert to previous LAMW....
No! You need only update your sdk!!!
ViewLogin.Init(gApp);
I mean, it's actEasel... :D
You code:QuoteViewLogin.Init(gApp);
What about: ViewLogin.InitShowing(gApp); ??
No, it's just a sample what I'm doing in TViewLogin's JNI_Prompt. Because of that design time problem, I am tired to clear edUsername.Text every time I open project so I add that into JNI_Promt. After removing them it's still same, I can't init TViewLogin or any actEasel forms.
hummmm... and do you need:
after "ViewLogin.Init(gApp)" ???
if not Assigned(ViewLogin) then
begin
gApp.CreateForm(TViewLogin, ViewLogin);
ViewLogin.Init(gApp); // <- Don't show actEasel forms...
ViewLogin.pnView.SetViewParent(pnView); // <- here you are.
end;
AndroidModule2.jPanel1.BringToFront(); // << --- What about??
It's same, it will start crash on this line "AndroidModule2.Init(gApp)".QuoteAndroidModule2.jPanel1.BringToFront(); // << --- What about??
Do not use animation mode in actEasel....
So, the jPanel animation on "BringToFront" will be lost?I think so. I don't know what is wrong with that in the Android 8.0.0, maybe we should disable that for now until we know what the problem, I'm not pretty sure if it caused by Java template (maybe?), because I don't understand Java when I tried to inspect the codes. :D
I don't know what is wrong with that in the Android 8.0.0...
I think there's something is wrong....
I just found the LAMW.ini in the Lazarus config folder. That's why it trying to copying my old LAMW.QuoteI think there's something is wrong....
Yes! your jPanel.java is outdated!!!!!
I added some functionality to the jBitmap, jCanvas, and jDrawingView component classes....
There was a problem while displaying Cyrillic in DrawText functions......
I'll post the source code a bit later.
can be implemented in LAMW?
I found this but is a java code
@SegatorQuoteI found this but is a java code
Done!
implement as jForm methods...
var Uri: jObjectRef; begin .................... ShowMessage(Self.GetRealPathFromURI(Uri)); ............................................ end;
I modified my example ....
I venture to suggest that the name of the original file is taken from the component class name, which is written in Pascal,....
"LAMW: Lazarus Android Module Wizard"
Author: Jose Marques Pessoa
https://github.com/jmpessoa/lazandroidmodulewizard
:: How to Create JNI Bridge Component code::
1. LAMW Component Model:
:: jControl: No GUI Control
hint: you can use composition or inheritance model here....
:: jVisualControl: GUI Control
warning: you MUST use inheritance model here.....
2. Creating a new component:
2.1. Right click Java tab:
2.1. Insert a new [wrapper] java class jControl/jVisualControl from template;
hint1. Alternatively, you can paste you java code [template compatible] from clipboard!
hint2. Alternatively, you can import a "JAR" file and selec a class [at the moment, only for no visual control]!
hint3: You can also use the demo AppTryCode3 to produce a complete [wrapper] java class !
hint4. you do not need to build the "perfect" component now .... later you can add more methods, events and properties! [sections 3 e 4 bellow]
warning/important: All "imports" from "Controls.java" template and new "imports" from you java class code
will be researched to try write the correct JNI methods signatures.....
2.2. Rename [and extends] the new class [and constructor], write some custom field, methods, etc...
[for "JAR" imported class this task is automated! ]
guideline: please, preferentially init your news params names with "_", ex: int _flag, String _hello ...
hint1: Only public methods will be translated to pascal [bridge] code.
hint2: use the mask /*.*/ to make a public method invisible for the parse [ex. /*.*/public myfunctio() {....} ]
2.3. Select all the new java class code and right click it [java tab] .
hint1: if have only one java class code you do not need select it! just right click it!
hint2. save your java class source code in LAMW folder "......\android_wizard\smartdesigner\java" :
warning: the LAMW java to pascal convert dont support complex/generic types like "java.util.Map<,>" , "java.util.Set<>" etc..
So, we need re-write the method signature [by hand] for primitives data/array type....
But simple java Object param [or return] is ok [including array!!!]!
public void SetImage(Bitmap _image) { //<<---- OK!
this.setImage(_image);
}
public Bitmap GetImage(Bitmap _image) { //<<---- OK!
return this.getImage();
}
warning/important: All "imports" from "Controls.java" template and new "imports" from you java class code
will be researched to try write the correct JNI methods signatures.....
2.4. Popup Menu: Select "Write [Draft] Pascal jControl/jVisualControl Interface".
2.5. Right click Pascal Tab and select "Register Component..." from Popup Menu;
warning: Mac users: please, you must copy the console app "lazres" [lazarus/tools] to the folder
".../LazAndroidWizard/ide_tools";
2.6. [Dialog]: select a 16x16 PNG icon file;
2.7. [Dialog]: open a "register_*.pas" file (ex. "register_extra.pas"); **
hint: you can select "register_template.pas" to write a custom register file,
but, then, you must insert it into "tfpandroidbridge_pack.lpk".
2.8. Ok. You got you DRAFT pascal component JNI stuff! Please, look in the folder "..../LazAndroidWizard/android_bridges"
directory:
:: *.pas <--- open and fix/complete the pascal code with your others events/properties/methods/variables/overload!
:: *_icon.lrs <--- new icon resource
:: register_extras.pas <--- updated! by default, the new component will be include there!
2.9. [Lazarus IDE Menu]: Package -> Open Package File (*.lpk) --> "tfpandroidbridge_pack.pas" in folder
"....../LazAndroidWizard/android_bridges".
2.10. [Package Wizard]: Compile --->> Use ---> Install.
Warning: to compile/install/reinstall a LAMW package in Lazarus/Laz4Android [windows],
please, open a "dummy" pure windows project.... you MUST always close the cross compile project!
2.11. Wait .... Lazarus re-building ...
2.12. The new component is on "Android Bridges Extra" [or other...] palette!.
3. Added more methods to your component
3.1. write new method to your ".java" code
ex.
public void SetFoo(int _foo) {
mFoo = _foo;
}
public int GetFoo() {
return mFoo;
}
3.1. In java tab write a draft java class code to wrapper the [new] methods;
class jMyComponent {
public void SetFoo(int _foo) {
mFoo = _foo;
}
public int GetFoo() {
return mFoo;
}
}
3.2 Right click the Java tab and select "Write [draft] complementary Pascal Interface"
3.4 Copy the the pascal interface code to your component unit!!!
4. Added "native" [events] methods to your component
4.1. write the native method "call" to to your ".java" code [study some LAMW code as example!]
ex1: [from jSpinner.java]
controls.pOnSpinnerItemSelected(pascalObj,position,caption); //return void
ex2: [fiction...]
int i = controls.pOnSpinnerItemSelected(pascalObj,position,caption); //return int
ex3: [fiction...]
int[] v;
v = controls.pOnSpinnerItemSelected(pascalObj,position,caption); //return int[]
for (int i = 0; i < v.length; i++) {
//Log.i("v["+i+"]", ""+v); //do some use...
}
ex4: [fiction...]
String[] s;
s = controls.pOnSpinnerItemSelected(pascalObj,position,caption); //return String[]
for (int i = 0; i < s.length; i++) {
//Log.i("s["+i+"]", ""+s); //do some use...
}
4.2. write the native method signature to your [component] ".native" file [study some LAMW code as example!]
ex1. [from jSpinner.native]
public native void pOnSpinnerItemSelected(long pasobj, int position, String caption);
ex2. [fiction...]
public native int pOnSpinnerItemSelected(long pasobj, int position, String caption);
ex3. [fiction...]
public native int[] pOnSpinnerItemSelected(long pasobj, int position, String caption);
ex4. [fiction...]
public native String[] pOnSpinnerItemSelected(long pasobj, int position, String caption);
4.3. In java tab write a draft java class code to wrapper the the native [one line!] method;
class jMyComponent {
public native void pOnMyComponentItemSelected(long pasobj, int position, String caption); //MyComponent
}
NOTE: the "//MyComponent" signs the part of the method name that will be overshadowed in the nomination of the property.
ex. FOnItemSelected [ not FOnMyComponentItemSelected ]
4.4 Right click the Java tab and select "Write [draft] complementary Native Method Pascal Interface"
4.5 Copy the the pascal interface code [generated] to your component unit [mycomponent.pas] and to "Laz_And_Controls_Events.pas"!!!
Congratulations!!!
How to build Android App Bundles?
This release does not comply with the 64-bit Google Play requirements
splits {
abi {
enable true
reset()
include 'arm64-v8a'
universalApk false
}
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a','arm64-v8a'
universalApk true
}
}
In my case, Lazarus IDE now produces a 32 bit library, and then I separately call a script that compiles the project again, with the 64 bit compiler this time.
At that point, both of the above folders will have the libcontrols.so file in them. If you then build the APK, both versions (32 bit and 64 bit) will be included in the APK. And when you will submit it to google, it will be accepted.
How to build Android App Bundles?
Not using Android App Bundles is NOT the reason why your app is rejected by Google Play (see below for the real reason).
Android App Bundles (AAP files) are the *recommended* format by google, but APK files are accepted.
Android App Bundles's (AAB) advantage over APK is this: when people will download your app from google's play store, if you uploaded your app in AAB format, the user will only receive one version of the library, the one they need: downloading to a 64-bit phone will get only the 64 bit library, and downloading to a 32-bit device will get only the 32-bit files. If instead you uploaded your app as APK, all the users will receive all the files, 32 and 64 bit. I think they call that a "fat" bundle.
So AAP files are better for your users (no space wasted on their memory and in downloaded bandwidth). But APK are still accepted.
In order to create AAB bundles, I believe you need to use Android Studio to build the app, although I hope that at some point the Lazarus package will become able to do that as well.
But my suggestion is to stick with APK for the time being. You already have enough complicated things to work out, and you don't need one more...
And now the important thing:This release does not comply with the 64-bit Google Play requirements
The reason why you app was not accepted is that it didn't contain a 64-bit version of the library.
By default, LAMW/Lazarus generates 32-bit version of the library (libcontrols.so is the default name) which contains the Pascal code you write with LAMW.
Since August 2019, google requires a 64 bit version of any native libraries (so files) and refuses to accept APK (or AAB) files that only contain 32-bit versions of embedded libraries.
32-bit libraries are stored in the folder "libs\armeabi-v7a" in your app's main folder.
(you will probably see the file libcontrols.so in that folder)
64-bit libraries are stored in the folder "libs\arm64-v8a" in your app's main folder.
(you will probably find this folder empty)
What you need to do to get your app accepted by google is to set up a separate 64-bit FPC compiler, which targets arm64 CPUs, and compile your project a second time with it, so that the 64-bit file will be created and added to the libs\arm64-v8a folder.
I had to struggle a lot to figure this out. More recently, fpdeluxe and other projects are making the task of building both 32 and 64 bit versions easier.
In my case, Lazarus IDE now produces a 32 bit library, and then I separately call a script that compiles the project again, with the 64 bit compiler this time.
At that point, both of the above folders will have the libcontrols.so file in them. If you then build the APK, both versions (32 bit and 64 bit) will be included in the APK. And when you will submit it to google, it will be accepted.
Any Idea why I would get : Didn't find class "robert.gilland.moviemaster.jFileProvider?
Hello!
Tell me, please, is it possible to debug an Android application created using LAMV on a real device and how to do it.
How can I use external storage permission...
How to: Handling Firebase Push Notification in LAMW [warning: "beta" version :: 23-July-2021]
(by jmpessoa)
0) Create your "AppCompat" [[theme]] project
0.1)Put a "jsFirebasePushNotificationListener" component on form
0.2)Go to lazarus menu and simply "Run" --> "Build"
1) Login in your google acount [email or any....]
2) Go to "https://console.firebase.google.com/"
3) Create/Add a new Project [ex: "MyOrg"]
4) Go to your "MyOrg" project and click "+Add app"
5) Click on Android Icon
6) In (page) "Add Firebase to your Android app":
6.1) "Register App"
6.1.1 ""Android package name"
ex: org.lamw.appcompatfirebasepushnotificationlistenerdemo1
6.1.2 CLICK the button "Register app"
6.2) "Download config file"
get the "google-services.json" and put it in your LAMW project folder
Done!
(don't do anything more, LAMW takes care of it all for you!)
7) Active your Internet phone/device connection
8) Go to Lazarus menu "Run" --> "[LAMW] Build Android Apk and Run"
9) Go to "https://console.firebase.google.com/"
9.1 Click the "MyOrg" project
9.2 In the left panel/menu page go to "Engage" --> "Cloud Messaging"
9.3 Click "New notification" Button
9.4 Fill the form and click "Next"
9.5 In the "Target" --> "selectan app" [select your app package...] and "Next"
9.6 In the "Scheduling" --> "Now" and "Next"
9.7 In the bottom page click the button "Review"
9.8 "Publish" !!!!
Congratulations!!!
10) Notes about your/custom Payload expected by LAMW component:
[https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en]
10.1 Notification Payload
{
"message":{
- ...
...
"notification":{
"title" : "my message title", // ---> "title" expected by LAMW
"body" : "my message body" // ---> "body" expected by LAMW
}
...
...
}
}
Note: Notification messages are delivered to the notification tray when the app is in the background.
For apps in the foreground, messages are handled/delivery by a LAMW callback function for you !!!
10.2 Data Payload
{
"message":{
...
...
"data":{
"title":"my message title",// ---> "title" expected by LAMW
"body":"my message body", // ---> "body" expected by LAMW
"myKey1":"myValue1" //free/custom
"myKey2":"myValue2" //free/custom
...... //free/custom
}
...
...
}
}
Where myKey1, myKey2, .... are your free/custom key=value pairs ....
warning: from "data" messages only "title" and "body" are handled/delivery by the LAMW callback function for you
but you can read all "data" when App is "waking up" by clicking in notification....
//by code:
procedure TAndroidModule1.AndroidModule1ActivityCreate(Sender: TObject; intentData: jObject); var data: TDynArrayOfString; i, count: integer; begin data:= jIntentManager1.GetBundleContent(intentData, '='); //key=value count:= Length(data); for i:= 0 to count-1 do begin ShowMessage(data[i]); //key=value end; end;
//and/or maybe:
procedure TAndroidModule1.AndroidModule1NewIntent(Sender: TObject; intentData: jObject); var data: TDynArrayOfString; i, count: integer; begin data:= jIntentManager1.GetBundleContent(intentData, '='); //key=value count:= Length(data); for i:= 0 to count-1 do begin ShowMessage(data[i]); //key=value end; end;
10.3 Mixing Notification and Data Payload
{
"message":{
...
"notification":{
"title" : "my message title", // ---> "title" expected by LAMW
"body" : "my message body" // ---> "body" expected by LAMW
}
"data":{
"myKey1":"myValue1" //free/custom
"myKey2":"myValue2" //free/custom
......
}
...
...
}
}
10.4 WARNING: "beta" version :: 23-July-2021
10.5 References
https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en
Is it posibble in near future LAMW modify firebase db
//handling file by uri....
function GetBitmapFromUri
function GetTextFromUri
procedure SaveImageToUri
procedure SaveTextToUri
New demo:
"AppPublicFoldersAccessDemo1"
But, if possible, can you submit a "pull request" for changes in github?
I have never used github before, I need to figure out how to do that, I’ll do that a little later.
can you submit a "pull request" for changes in github?
I have made two "pull requests" for changes in github for two files (jForm.java, androidwidget.pas).
Hi, All!
LAMW "0.8.6.2" moving to Android API >= 30 !!!
Please, update your android sdk/platforms folder!
How to:
.open a command line terminal and go to android folder "sdk/tools/bin"
.run the command >>sdkmanager --update'
.run the command >>sdkmanager "build-tools;30.0.2" "platforms;android-30"
Thanks to All!
Recently someone reported this issue when installing Lazarus from trunc ....
Are you using trunc version?