Recent

Author Topic: Android Module Wizard  (Read 707698 times)

lucabertoncini

  • New member
  • *
  • Posts: 7
Re: Android Module Wizard
« Reply #975 on: July 17, 2017, 01:40:17 pm »
Hi JMPessoa,
thanks for your time.
I took a look at the demos to try to understand how to use this interesting code.
If I’m right, to be able to post a JSON string with jHTTPClient I should write a procedure similar to jHTTPClient_AddValueForPost2 but with only a single parameter.


Something like

procedure jHTTPClient_AddStringForPost(env: PJNIEnv; _jHTTPClient: JObject; _AString: string);
  var
  jParams: array[0..0] of jValue;
  jMethod: jMethodID = nil;
  jCls: jClass = nil;
begin
  jParams[0].l := env^.NewStringUTF(env, PChar(_AString));
  jCls := env^.GetObjectClass(env, _jHTTPClient);
  jMethod := env^.GetMethodID(env, jCls, 'AddStringForPost', '(Ljava/lang/String;)V');
  env^.CallVoidMethodA(env, _jHTTPClient, jMethod, @jParams);
  env^.DeleteLocalRef(env, jParams[0].l);
  env^.DeleteLocalRef(env, jCls);
end;

What about an https connection? In Android I need to use a different object  HttpsURLConnection.
In this case I need to change the function jHttpClient_Post with this:
jMethod := env^.GetMethodID(env, jCls, 'Post', '(Ljava/net/HttpsURLConnection;)Ljava/lang/String;');

These are the two test I'll do in the next days. Do you think it is the right way?

lucabertoncini

  • New member
  • *
  • Posts: 7
Re: Android Module Wizard
« Reply #976 on: July 17, 2017, 05:00:27 pm »
I've found this tutorial.

http://www.pacifier.com/~mmead/jni/delphi/JEDI/DOCS/delphi-jni-1.html

Everything I wrote in the previous post was wrong!

I'll try the way of using fphttpclient and fpsock library.

Thank you!

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #977 on: July 17, 2017, 06:16:08 pm »

Quote
http://www.pacifier.com/~mmead/jni/delphi/JEDI/DOCS/delphi-jni-1.html

Yes, a great "core" tutorial....

But LAMW code architecture is much easier!

First we write a java class to wrapper some android API..
Example:  jHttpClient is a wrapper for android HttpsURLConnection...
See the demos "AppHttpClientDemo1" and AppHttpClientDemo2 .....AppHttpClientCookiesDemo1, etc...
You can see the java stuff in folder "YourProject/scr/........."

Note: To use fpc FCL core, you often need to copy the source code to you project
"jni"  folder ....
Example: To use  "fphttpclient" copy "fphttpclient.pp",  "httpdefs.pp" and "httpprotocol.pp" to you project "jni" folder

But, I think you can try first the LAMW jComponents!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

lucabertoncini

  • New member
  • *
  • Posts: 7
Re: Android Module Wizard
« Reply #978 on: July 17, 2017, 06:23:32 pm »
Ok, in the next days I'll go deeper. Thanks!

c4p

  • Full Member
  • ***
  • Posts: 158
Re: Android Module Wizard
« Reply #979 on: August 23, 2017, 11:09:43 am »
Just a note of thanks to jmpessoa and others contributing to the fantastic LAMW project.  8-)

 :D
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

januszchmiel

  • New Member
  • *
  • Posts: 15
Re: Android Module Wizard
« Reply #980 on: September 01, 2017, 08:48:32 pm »
Dear specialists,
I Am new user on this forum. My name is Janusz Chmiel. I Am visually impaired user with no sight at all. I would like to express my deepest possible appreciation to all of you, who have developed so amazing component for Lazarus. I AM able to use all of yours provided demo examples while using it with Talkback screen reader. I Am very very glad, that you have enabled visually impaired to use compiled Android apps created by using yours component. I have only one programmers plea to you. When programmer add background special command, so app can run at background. Does running program allocate so much RAM, that Android memory management can start to automatically kill some processes? I AM afraid, that if I will listen live Internet radio and app will run at The background, that app will automatically allocate so much RAM, that my favourite Talkback screen reader would be automatically terminated by Android memory management algorithms. Or I do not have to have fair because of it. Because resulting app is optimized also because of RAM allocations? Sure, I know, that it depend also on programming techniques which will be used by Pascal programmer. Really, very well done. I have never thought, that i would be able to find so perfect freeware solution.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #981 on: September 03, 2017, 09:48:15 pm »
Quote
Does running program allocate so much RAM, that Android memory management can start to automatically kill some processes?

Yes...  and  Android algorithm has often changed....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

januszchmiel

  • New Member
  • *
  • Posts: 15
Re: Android Module Wizard
« Reply #982 on: September 07, 2017, 06:21:17 pm »
Dear specialists,
Would somebody of us write me commands, which I had to add to have wakelock set to The walue, so background tasks will be working even when I turn The phone screen off? If I will place such commands to The unit1.pas and external .so library will be called from here. Will be wakelock applied also for internal machine code of native C .so library which will be called? I Am afraid, that Android would suspend threads from native external library. Or i do not have to think so? So please, which lines and which commands should be part of The .pas source code? Thank you very much.
« Last Edit: September 07, 2017, 06:24:19 pm by januszchmiel »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #983 on: October 09, 2017, 11:21:56 pm »

Hi All,

The "Skywave Radio Schedules" app  by  @c4p
[powered by FPC+Lazarus+LAMW !]

is  now on Google Play!

https://play.google.com/store/apps/details?id=swbcdx.cap.shortwavelist

thanks and congratulations to  @c4p!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #984 on: October 15, 2017, 01:20:44 am »
Hi All,

There is a LAMW update! [improved support to material theme]

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

Version 0.7 - rev. 21 - 14 - October - 2017

   NEW! jToolbar component  [to use only with  "minSkd=21" and "targetSdk >= 21"] <<--- a request from @Tomash

   NEW! demo AppToolbarDemo1 [generic use of jToolbar as a specialized panel/visualContainer]

   NEW! demo AppToolbarDemo2 [use Toolbar as "Actionbar". NOTE: configured theme/style as "android:Theme.Material.Light.NoActionBar"
               in "...res\values-21\style.xml"]

      HINT 1: Configure your project colors:

         Go to project folder "....res/values/colors.xml" <----- change [only content, NOT the file name] to configure colors
            
            Reference is here:
            http://www.vogella.com/tutorials/AndroidStylesThemes/article.html#styling-the-color-palette

      HINT 2: if you change default ["colbrRoyalBlue"] jToolbar background color in design time,
         You should change "primary_dark" in "color.xml" according "material" guideline
         [a little more darker than the toolbar color]
         Reference is here: https://www.materialpalette.com/   


Thanks to All!
« Last Edit: October 15, 2017, 01:23:15 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #985 on: October 22, 2017, 08:38:26 pm »

Hi All,

There is a LAMW update!

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

Version 0.7 - rev. 22 - 21 - October - 2017

   NEW! jExpandableListView component

   NEW! demo AppExpandableListViewDemo1

   IMPROVED! jTextToSpeech
         Added method "SpeakOnline"   [Thanks to  @Freris]


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

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #986 on: November 05, 2017, 08:24:35 am »
hi jmpessoa
can i implement admob to my app ?  :) :)

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #987 on: November 07, 2017, 05:42:02 am »
Hi m4u!

I will try implement admob support as soon as possible!

[At the  moment, I am working to add gradle support ....]
« Last Edit: November 07, 2017, 05:46:30 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #988 on: November 12, 2017, 04:47:08 am »
I use laz4android 1.7
newest lamw version
If i create new project with 2 forms, form1 has 1 jbutton, when I create second form, IDE will crash
I dont know why

If i dont use jbutton and use jimgbutton instead, everything is ok

I tried some cases
I have 2 forms, if form1 has jbutton,jedittext,jlabel,jradiobutton,jcheck , the form2 cant have those because IDE will crash
I concluded I just can put those components on 1 form, other forms have them will cause IDE crash
« Last Edit: November 12, 2017, 05:21:10 am by m4u_hoahoctro »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: Android Module Wizard
« Reply #989 on: November 12, 2017, 07:09:02 am »
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.

 

TinyPortal © 2005-2018