* * *

Author Topic: Android Module Wizard  (Read 313455 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: 936
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

  • Jr. Member
  • **
  • Posts: 67
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

januszchmiel

  • Newbie
  • Posts: 2
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: 936
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

  • Newbie
  • Posts: 2
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 »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus