Recent

Author Topic: Android Module Wizard  (Read 474055 times)

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 159
Re: Android Module Wizard
« Reply #1125 on: November 07, 2018, 10:02:59 am »
@jmpessoa
Today i built a location app, it seems be the code:

Code: Pascal  [Select]
  1. url:=jLocation1.GetGoogleMapsUrl(lat,lng);
  2. jWebview1.Navigation(url);

cant be used anymore. Google page shows that "You must use an API key to Google Maps Platform". :) :)

And I realize that jWebview hasnt scroll  :o :o ?
« Last Edit: November 07, 2018, 10:29:01 am by m4u_hoahoctro »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7996
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android Module Wizard
« Reply #1126 on: November 08, 2018, 02:48:32 am »
@jmpessoa
Today i built a location app, it seems be the code:

Code: Pascal  [Select]
  1. url:=jLocation1.GetGoogleMapsUrl(lat,lng);
  2. jWebview1.Navigation(url);

cant be used anymore. Google page shows that "You must use an API key to Google Maps Platform". :) :)

And I realize that jWebview hasnt scroll  :o :o ?
The code is 2 years old. I believe last year google maps started to lose its free (as in no API key needed) service. Today even your free calls require an API key, with limited number of calls per day (not really remember how many, probably 1000). The code definitely needs an update.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1221
Re: Android Module Wizard
« Reply #1127 on: November 09, 2018, 06:39:16 am »

About "jLocation" component and "AppLocationDemo1":

Fixed and updated!

Please, set the new property "GoogleMapsApiKey"

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

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 159
Re: Android Module Wizard
« Reply #1128 on: November 10, 2018, 11:14:44 am »

About "jLocation" component and "AppLocationDemo1":

Fixed and updated!

Please, set the new property "GoogleMapsApiKey"

Thanks!

@jmpessoa, thanks for updating  :) :)
but how can we set scrolldown property for jWebView ?  :)

jmpessoa

  • Hero Member
  • *****
  • Posts: 1221
Re: Android Module Wizard
« Reply #1129 on: November 18, 2018, 10:11:02 pm »
Hi, m4u!

I did this test:

jWebView1.Navigate('http://forum.lazarus-ide.org/index.php?action=forum');     

and the  jWebView  "scrolling"  is  OK!
« Last Edit: November 19, 2018, 05:39:39 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1130 on: November 30, 2018, 02:30:10 pm »
Hi, can anyone help me how to create a TCPSocketClient component at runtime?
Thank you!

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1131 on: November 30, 2018, 02:32:25 pm »
sorry the correct name is jTCPSocketClient

jmpessoa

  • Hero Member
  • *****
  • Posts: 1221
Re: Android Module Wizard
« Reply #1132 on: December 01, 2018, 08:15:18 pm »
Quote

 how to create a jTCPSocketClient component at runtime?

You can try mimic this code:
[note that you will necessarily need an component of the same type on the form!!!]

Code: Pascal  [Select]
  1. {Hint: save all files to location: C:\lamw\workspace\AppNiceProject1\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, tcpsocketclient;
  10.  
  11. type
  12.  
  13.   { TAndroidModule1 }
  14.  
  15.   TAndroidModule1 = class(jForm)
  16.     jButton1: jButton;
  17.     jTCPSocketClient1: jTCPSocketClient;
  18.     jTextView1: jTextView;
  19.     procedure AndroidModule1Create(Sender: TObject);
  20.     procedure jButton1Click(Sender: TObject);
  21.     procedure jTCPSocketClient1BytesReceived(Sender: TObject;
  22.       var jbytesReceived: TDynArrayOfJByte);
  23.     procedure jTCPSocketClient1Connected(Sender: TObject);
  24.  
  25.   private
  26.     {private declarations}
  27.     IsNewStuffCreated: boolean;
  28.   public
  29.     {public declarations}
  30.    jButtonRuntime: jButton;
  31.    jTCPSocketClientRuntime: jTCPSocketClient;
  32.   end;
  33.  
  34. var
  35.   AndroidModule1: TAndroidModule1;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41.  
  42. { TAndroidModule1 }
  43.  
  44. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  45. begin
  46.    if (Sender as jButton).Tag = 1 then
  47.    begin
  48.  
  49.      if not IsNewStuffCreated then
  50.      begin
  51.  
  52.        jButtonRuntime:= jButton.Create(Self);  //pascal side button
  53.        jButtonRuntime.Tag:= 2;
  54.        jButtonRuntime.Text:= 'jButtonRuntime';
  55.        jButtonRuntime.LayoutParamWidth:= lpHalfOfParent;
  56.        jButtonRuntime.Anchor:= jButton1;
  57.        jButtonRuntime.PosRelativeToAnchor:= [raBelow];
  58.        jButtonRuntime.PosRelativeToParent:= [rpCenterHorizontal];
  59.        jButtonRuntime.OnClick:= jButton1Click;  //delphi mode...
  60.        jButtonRuntime.Init(gApp);    //java side button
  61.  
  62.        jTCPSocketClientRuntime:= jTCPSocketClient.Create(Self);
  63.        jTCPSocketClientRuntime.Tag:= 2;
  64.        jTCPSocketClientRuntime.OnConnected:= jTCPSocketClient1Connected;
  65.        jTCPSocketClientRuntime.OnBytesReceived:= jTCPSocketClient1BytesReceived;
  66.        jTCPSocketClientRuntime.Init(gApp);
  67.  
  68.        IsNewStuffCreated:= True; // <-----
  69.  
  70.      end
  71.      else
  72.      begin
  73.        ShowMessage('Warning: jButtonRuntime was created!');
  74.      end;
  75.  
  76.    end;
  77.  
  78.    if (Sender as jButton).Tag = 2 then
  79.    begin
  80.       ShowMessage('Hello from created jButtonRuntime !!!');
  81.    end;
  82.  
  83. end;
  84.  
  85. procedure TAndroidModule1.jTCPSocketClient1BytesReceived(Sender: TObject;
  86.   var jbytesReceived: TDynArrayOfJByte);
  87. begin
  88.  
  89.    if (Sender as jTCPSocketClient).Tag = 1 then
  90.    begin
  91.  
  92.    end;
  93.  
  94.    if (Sender as jTCPSocketClient).Tag = 2 then
  95.    begin
  96.  
  97.    end;
  98.  
  99. end;
  100.  
  101. procedure TAndroidModule1.jTCPSocketClient1Connected(Sender: TObject);
  102. begin
  103.  
  104.    if (Sender as jTCPSocketClient).Tag = 1 then
  105.    begin
  106.  
  107.    end;
  108.  
  109.    if (Sender as jTCPSocketClient).Tag = 2 then
  110.    begin
  111.  
  112.    end;
  113.  
  114. end;
  115.  
  116. procedure TAndroidModule1.AndroidModule1Create(Sender: TObject);
  117. begin
  118.   jButton1.Tag:= 1;
  119.   jTCPSocketClient1.Tag:= 1;
  120.   IsNewStuffCreated:= False;
  121. end;
  122.  
  123. end.
  124.  

Here is a good place to create/modify  java stuff,  too ...
Code: [Select]
procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin

end;

« Last Edit: December 01, 2018, 08:21:42 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

abssistemas

  • New member
  • *
  • Posts: 21
Re: Android Module Wizard
« Reply #1133 on: December 03, 2018, 02:04:40 pm »
It worked perfectly.
Now how do I make my android application run in the background?

Adromir

  • Newbie
  • Posts: 4
Re: Android Module Wizard
« Reply #1134 on: December 28, 2018, 05:15:34 am »
I am trying to get it Run according to the Install instructions on the Wiki but its totally unsuccessfull i get a lot of Errors that fr example folders are empty or paths don't match although i made it step by step exactly how the Wiki describes it. Can anyone help me? Maybe there is something new required not Mentioned in the Wiki?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1221
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Adromir

  • Newbie
  • Posts: 4
Re: Android Module Wizard
« Reply #1136 on: December 30, 2018, 07:13:32 pm »
Thanks I got it Running with that. Still got an Access- Violation when i opened and importet a Project, but still worked when i ignored that. Maybe a few suggestions:

1. Could the Install Cross Compile Wizard save the Location of the Source? I mean its not needed often, but a bit annoying when you start to setup your environment
And another Hint maybe for the Setupinstructions: Apparently Gradle sometimes need a properly set JAVA_HOME variable. Compiling didn't work on my system at the beginning (WIN10), because I also had JDK10 installed
2. I believe FPC Trunk now supports a new range of Android Cross Compilers. Are you planning to support them?
3. As the Target of the Project is set up through the Wizard, is there any way to change that? Like switching from arm to x86?

sohag

  • Newbie
  • Posts: 1
Re: Android Module Wizard
« Reply #1137 on: January 12, 2019, 06:49:05 am »
How to place checkbox on jsRecyclerView