Recent

Author Topic: Android Module Wizard  (Read 505778 times)

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1095 on: September 08, 2018, 05:22:19 am »
Hi  abssistemas!

Attached is a new java template .....

Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

Please,  test the "SendBytes" and also the "SendMessage"

Thank you!!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

DelphiFreak

  • Full Member
  • ***
  • Posts: 246
    • Fresh sound.
Re: Android Module Wizard
« Reply #1096 on: September 09, 2018, 11:49:24 am »
Hello,

I have a wish for the next version.
Could you place a button like this (see attachment).

It would open the explorer at the location of the .apk-file.

As I found here https://www.askingbox.com/question/lazarus-open-folder-in-explorer it should be easy.

OpenDocument('C:\Example');

Thank you.


Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

A.S.

  • Jr. Member
  • **
  • Posts: 74
Re: Android Module Wizard
« Reply #1097 on: September 09, 2018, 07:34:31 pm »
Hello,

I have a wish for the next version.
Could you place a button like this (see attachment).

It would open the explorer at the location of the .apk-file.

As I found here https://www.askingbox.com/question/lazarus-open-folder-in-explorer it should be easy.

OpenDocument('C:\Example');

Thank you.
Not sure "Android emulators" window is a correct place for such button. This dialog is intended to start AVDs. If some AVD is already started (or real devices is connected via USB), this dialog won't be shown.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1098 on: September 10, 2018, 06:04:25 am »

Hi All,

About "ide-tools" package:

the menu option "[LAMW] Android Module Wizard" 

now can:

"Convert the Project to AppCompat Theme"

and

"Use/Import LAMW Stuff..."    [form reuse!!!]

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

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1099 on: September 10, 2018, 01:47:03 pm »
Hi  abssistemas!

Attached is a new java template .....

Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

Please,  test the "SendBytes" and also the "SendMessage"

Thank you!!!

I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1100 on: September 10, 2018, 07:55:31 pm »
@abssistemas

[jTCPSocketClient componet]
Quote
I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.

Thank you!!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1101 on: September 22, 2018, 04:48:41 pm »
@abssistemas

[jTCPSocketClient componet]
Quote
I tested the new java file and it worked, both in the "SendMessage" method and "SendBytes", perfect.

Thank you!!!

I need to now get bytes from the jTCPSocketClient component, because the OnMessagesReceived event returns an array of string and would have to be an array of bytes.
Would you be able to modify the component to receive bytes instead of string?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1102 on: September 23, 2018, 07:32:38 am »
Quote
Would you be able to modify the component to receive bytes instead of string?

Done!!!

Code: Pascal  [Select]
  1. procedure TAndroidModuleTCP.jButton1Click(Sender: TObject);
  2. begin
  3.  
  4.   //NEW!!! Prepare to "Send" and "Receive"  bytes
  5.   jTCPSocketClient1.SetDataTransferMode(dtmByte);  
  6.  
  7.   jTCPSocketClient1.ConnectAsync('192.168.0.105', 54321);
  8. end;
  9.  


Code: Pascal  [Select]
  1. //Handle Bytes Received ....
  2. procedure TAndroidModuleTCP.jTCPSocketClient1BytesReceived(Sender: TObject;
  3.   var bytesReceived: TDynArrayOfJByte);
  4. var
  5.    i, count: integer;
  6. begin
  7.    count:=  Length(bytesReceived);
  8.    for i:= 0 to count-1 do
  9.    begin
  10.       ShowMessage(IntToStr(bytesReceived[i]))
  11.    end;
  12. end;
  13.  

Please, test it!!

Thank you!
« Last Edit: September 23, 2018, 07:35:51 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1103 on: September 24, 2018, 02:58:20 pm »
Quote
Would you be able to modify the component to receive bytes instead of string?

Done!!!

Code: Pascal  [Select]
  1. procedure TAndroidModuleTCP.jButton1Click(Sender: TObject);
  2. begin
  3.  
  4.   //NEW!!! Prepare to "Send" and "Receive"  bytes
  5.   jTCPSocketClient1.SetDataTransferMode(dtmByte);  
  6.  
  7.   jTCPSocketClient1.ConnectAsync('192.168.0.105', 54321);
  8. end;
  9.  


Code: Pascal  [Select]
  1. //Handle Bytes Received ....
  2. procedure TAndroidModuleTCP.jTCPSocketClient1BytesReceived(Sender: TObject;
  3.   var bytesReceived: TDynArrayOfJByte);
  4. var
  5.    i, count: integer;
  6. begin
  7.    count:=  Length(bytesReceived);
  8.    for i:= 0 to count-1 do
  9.    begin
  10.       ShowMessage(IntToStr(bytesReceived[i]))
  11.    end;
  12. end;
  13.  

Please, test it!!

Thank you!

I tested but it crashed when I connected it.
Without the jTCPSocketClient1.SetDataTransferMode (dtmByte) command it works normally.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1104 on: September 24, 2018, 06:46:12 pm »

Hi  abssistemas!

Attached is a new java template .....  I fixed "SetDataTransferMode"


Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

Please,  test the "SendBytes/OnBytesReceive" and also the "SendMessage/OnMessagesReceived"

Thank you!!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1105 on: September 25, 2018, 01:08:12 pm »
Hi jmpessoa

I tested the modification but it did not work.

No more crash.

"SendMessage / OnMessagesReceived" works.
"SendBytes" works.
"OnBytesReceive" does not work does not receive anything.
Here's my code:


type

  { TAndroidModuleMaps }

  TAndroidModuleMaps = class(jForm)
    procedure jButton2Click(Sender: TObject);
    procedure jTCPSocketClient1Connected(Sender: TObject);
    procedure jTCPSocketClient1MessagesReceived(Sender: TObject;
      messagesReceived: array of string);
    procedure jTCPSocketClient1BytesReceived(Sender: TObject;
      var bytesReceived: TDynArrayOfJByte);


procedure TAndroidModuleMaps.jButton2Click(Sender: TObject);
begin
  //NEW!!! Prepare to "Send" and "Receive"  bytes
  jTCPSocketClient1.SetDataTransferMode(dtmByte);

  jTCPSocketClient1.ConnectAsync('192.168.15.5',1024);

end;

procedure TAndroidModuleMaps.jTCPSocketClient1MessagesReceived(Sender: TObject;
  messagesReceived: array of string);
begin
  //aqui funciona
  ShowMessage('Recebido string');
end;


procedure TAndroidModuleMaps.jTCPSocketClient1BytesReceived(Sender: TObject;
  var bytesReceived: TDynArrayOfJByte);
begin
  //aqui não funciona
   ShowMessage('Recebido bytes');
end;


jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1106 on: September 26, 2018, 04:29:34 am »

Hi  abssistemas!

Attached is a new java template ..... 

Put this [unzipded!] "jTCPSocketClient .java" file in the  folder  "..... \java\lamwdesigner" of the LAMW framework ...

re-open your project and make a new build .... etc ....

I just inserted some "debug" tags...

Please,  keep this:

jTCPSocketClient1.SetDataTransferMode(dtmByte);
jTCPSocketClient1.ConnectAsync(....);

and test the "SendBytes"  ......

for debug,  "OnBytesReceive"  will try report  only 2  jbytes ....

"0" and "0"

OR

"-1" and "-1"

OR
 
of course, the bytes reported by your system...

You can report your test here...

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1107 on: September 26, 2018, 12:42:57 pm »
Hi jmpessoa,

You have not appended the java file.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: Android Module Wizard
« Reply #1108 on: September 26, 2018, 06:20:19 pm »

Sorry...  Fixed here!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1109 on: September 27, 2018, 04:23:57 pm »
With this line

jTCPSocketClient1.SetDataTransferMode(dtmByte);

It did not send, but without it is sending only string