Recent

Author Topic: Android Module Wizard  (Read 537549 times)

greenzyzyzy

  • Full Member
  • ***
  • Posts: 172
Re: Android Module Wizard
« Reply #450 on: May 23, 2015, 05:37:35 pm »
Hi All!

Thanks to  @rx3.fireproof, 

I  fixed an important "JNI ERROR (app bug): local reference table overflow"

Please, update you Lamw!!!

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

Hi rx3.fireproof!

I think now your memory management problems are solved!

Your nice App is running again!  :D :D :D  :-[ [Attachment]

hello jmpessoa ,
would you like to teach me how to pass a jstring array to a jvalue?
can i do it like this?


var
javaString:array [0..2]of jstring;
lParams: array[0..0] of JValue;
........
........
begin
  javaString[0]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'http://magnifier.sourceforge.net');
  javaString[1]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus');
  javaString[2]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus-ide');
lParams[0].l:=javaString;
...
end;

rx3.fireproof

  • New Member
  • *
  • Posts: 49
Re: Android Module Wizard
« Reply #451 on: May 23, 2015, 10:30:22 pm »
Hello Jmpessoa


I checked the latest fixes. Everything works fine.

Thank you very much.


With Respect

rx3.fireproof


ps

I will try to do a more complex form.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1483
Re: Android Module Wizard
« Reply #452 on: May 24, 2015, 02:23:39 am »
@rx3.fireproof,

Quote
would you like to teach me how to pass a jstring array to a jvalue?
can i do it like this?

var
javaString:array [0..2]of jstring;
lParams: array[0..0] of JValue;
........
........
begin
  javaString[0]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'http://magnifier.sourceforge.net');
  javaString[1]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus');
  javaString[2]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus-ide');
lParams[0].l:=javaString;
...
end;

There is a tutorial about string array [and others...]: "MyHello.pas" and the wrapper/counterparty "class jMyHello" in "Controls.java" !!

Demo: jMyHello component and app "AppTryCode1"

Minor diference:

We use "And_jni.pas" not "jni.pas", so we write:

"Env^.NewStringUTF(javaEnvRef, 'lazarus-ide');"

not   "Env^^NewStringUTF(javaEnvRef, 'lazarus-ide');"

etc...

But if you have a more specific need/requirement, please, put it here  ....


« Last Edit: May 24, 2015, 02:30:39 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #453 on: May 25, 2015, 06:09:18 am »
how can I load an image from sd card and show to form ?
@ jmpessoa: please help me about before problem that I asked  :-X

jmpessoa

  • Hero Member
  • *****
  • Posts: 1483
Re: Android Module Wizard
« Reply #454 on: May 25, 2015, 11:56:29 pm »
Hi m4u_hoahoctro!

You can try:

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  jimage1: jObject;     
begin 
    jimage:= jImageFileManager1.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirSdCard),'image1.png');
    jImageView1.SetImageBitmap(jimage1);
end;

There is a demo "AppShareFileDemo1", you can see others codes too....
« Last Edit: May 26, 2015, 04:12:53 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

greenzyzyzy

  • Full Member
  • ***
  • Posts: 172
Re: Android Module Wizard
« Reply #455 on: May 26, 2015, 05:45:22 am »
@rx3.fireproof,

Quote
would you like to teach me how to pass a jstring array to a jvalue?
can i do it like this?

var
javaString:array [0..2]of jstring;
lParams: array[0..0] of JValue;
........
........
begin
  javaString[0]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'http://magnifier.sourceforge.net');
  javaString[1]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus');
  javaString[2]:=javaEnvRef^^.NewStringUTF(javaEnvRef, 'lazarus-ide');
lParams[0].l:=javaString;
...
end;

There is a tutorial about string array [and others...]: "MyHello.pas" and the wrapper/counterparty "class jMyHello" in "Controls.java" !!

Demo: jMyHello component and app "AppTryCode1"

Minor diference:

We use "And_jni.pas" not "jni.pas", so we write:

"Env^.NewStringUTF(javaEnvRef, 'lazarus-ide');"

not   "Env^^NewStringUTF(javaEnvRef, 'lazarus-ide');"

etc...

But if you have a more specific need/requirement, please, put it here  ....


thank you very much.

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #456 on: May 26, 2015, 06:14:25 am »
Hi m4u_hoahoctro!

You can try:

Code: [Select]
procedure TAndroidModule1.jButton1Click(Sender: TObject);
var
  jimage1: jObject;     
begin 
    jimage:= jImageFileManager1.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirSdCard),'image1.png');
    jImageView1.SetImageBitmap(jimage1);
end;

There is a demo "AppShareFileDemo1", you can see others codes too....

thanks, but now: I can't add any procedure. It shows error:foward declaraction not solved

jmpessoa

  • Hero Member
  • *****
  • Posts: 1483
Re: Android Module Wizard
« Reply #457 on: May 26, 2015, 07:23:35 pm »
@ m4u_hoahoctro

Quote
...I can't add any procedure. It shows error:foward declaraction not solved

Where ? Please, put your code here.....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #458 on: May 27, 2015, 05:22:01 pm »
@ m4u_hoahoctro

Quote
...I can't add any procedure. It shows error:foward declaraction not solved

Where ? Please, put your code here.....

ok I will post code later  :)
hmm, I still have a question :-[: how do make a menu that subs menu can link to a procedure in program ?

and, seems be jmediaplayer can't open film file ?, I tried and it did't work  :'( ( example: mp4.mkv)
« Last Edit: May 29, 2015, 05:26:33 pm by m4u_hoahoctro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1483
Re: Android Module Wizard
« Reply #459 on: June 02, 2015, 05:02:46 pm »
Hi All!

There is an updated "Lamw/Lazarus Android Module Wizard" revision!

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

Version 0.6 - rev. 28 - 02 June 2015

   NEW!
      jForm "TakeScreenshot" method
      jForm "Vibrate" method
         :"AndroidManifest.xml" add on: 
            "<uses-permission android:name="android.permission.VIBRATE"/>"
   IMPROVEDMENTS!   
      jAsyncTask component:
         New! component design/behaviour  changed!
         News events properties:
                OnDoInBackground
            OnProgressUpdate
            OnPreExecute
            OnPostExecute

         ::Redesigned Demo : AppAsyncTaskDemo1             

      jHttpClient
         New! Added build in "asynctask" support!
         News events properties:
            OnContentResult
            OnCodeResult

         ::Redesigned Demo: AppHttpClientDemo1               
   
      jDialogProgress component //<--- Euller's suggestion!
         New! Added "custom view" support!
         News methods:                        
            Show
                            Close
            SetMessage
            SetTitle
            SetCancelable
   NEW! 
      Demo AppDialogProgressDemo1 [Eclipse Compatible Project]          

Thank to All!
« Last Edit: June 02, 2015, 05:13:16 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

renabor

  • Jr. Member
  • **
  • Posts: 67
Re: Android Module Wizard
« Reply #460 on: June 03, 2015, 04:03:31 pm »
Hello Jmpessoa
I have upgraded to latest version (rev. 28) but jHttpClient works no more.
I get this error:

java.lang.NoSuchMethodError: no method with name='Get' signature='(Ljava/lang/String;)V' in class Lcom/suevoz/hello/jHttpClient;

consider that the code is just the same that was working fine with rev. 27, with the only difference that now I'm using jHttpClient1ContentResult for retrieving the result of the Http request.

Any idea?

with respect
FPC 3.0.5 | Lazarus 1.8 | Ubuntu Gnome 17.10 64bit

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #461 on: June 03, 2015, 05:23:18 pm »
I have some errors when compiling project:
controls.lpr(231,3) Error: Identifier not found "Java_Event_pOnAsyncEvent"

Panic: tool stopped with exit code 1. Use context menu to get more information.

Fatal: [Exception] Failed: Cannot build APK!

Link of my project: https://drive.google.com/file/d/0Bx3SDL5wwBBYaHAxVVJhNUxwaXM/view?usp=sharing
« Last Edit: June 03, 2015, 05:55:42 pm by m4u_hoahoctro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1483
Re: Android Module Wizard
« Reply #462 on: June 03, 2015, 06:49:02 pm »
@m4u_hoahoctro

@renabor

Yes, we did dramatic changes, sorry!

Please, you can learn the new components design/behaviour in the Demos:  AppAsyncTaskDemo1 and AppHttpClientDemo1  !!!

1. jAsyncTask lost property "OnAsyncEvent" but no panic!
when prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Now copy the old code to matching/equivalent news events:
           OnDoInBackground
            OnProgressUpdate
            OnPreExecute
            OnPostExecute

2. jHttpClient: now "runInBackground/asynctask" have build in  support! You do not  need more use jAsyncTask component to run it "in background" !

ok, you will need handle the new event "ContentResult" to get content result and
"get" now is a procedure [not a function] ... so, no more result!

Again, sorry ...

but, the changes was for more elegance and effective solution! 

Thanks to All!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #463 on: June 04, 2015, 02:02:03 am »
@m4u_hoahoctro

@renabor

Yes, we did dramatic changes, sorry!

Please, you can learn the new components design/behaviour in the Demos:  AppAsyncTaskDemo1 and AppHttpClientDemo1  !!!

1. jAsyncTask lost property "OnAsyncEvent" but no panic!
when prompt "Read error" [Unknown Property] just choice "Continue Loading"!

Now copy the old code to matching/equivalent news events:
           OnDoInBackground
            OnProgressUpdate
            OnPreExecute
            OnPostExecute


can you explain more ? . copy old code ? I don't know how to find them ?  :-\

about error:

Identifier not found "Java_Event_pOnAsyncEvent"

and

Can't build apk file (If I create new project )

Sorry because I haven't understand your meaning yet  :-\

jmpessoa

  • Hero Member
  • *****
  • Posts: 1483
Re: Android Module Wizard
« Reply #464 on: June 04, 2015, 03:32:21 am »
@m4u_hoahoctro

QUESTION 1

Quote
about error:
....Identifier not found "Java_Event_pOnAsyncEvent"

solution: you need upgrade you project  code  templates .... [need by new revision]

Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

QUESTION 2

Quote
....copy old code ?

meaning [just example]:

Code: [Select]
case EventType of:

atsBefore: begin
                      // <------------ old code here! copy to new "OnPreExecute"
                 end;

atsInBackground: begin
                                  //<------------ old code here! copy to new "OnDoInBackground"
                             end;

atsProgress: begin
                          // <------------ old code here! copy to new " OnProgressUpdate"
                     end;

atsPost: begin
                    // <------------ old code here! copy to new "OnPostExecute"
              end;
« Last Edit: June 04, 2015, 03:52:15 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard