LAMW how to get html content from a webview component [SOLVED] lazarus / 43-Android ---------------------------------------------------------------------- Segator · 2020-08-15 19:19 Hi all and thanks for the lamw project, great job, i know about jhttpclient component but it not support javascript and other dinamic thinks required for some sites, so the webview components is the best way to show html content, but i can't get the information inside it, i make some search on google and found https://stackoverflow.com/questions/8200945/how-to-get-html-content- from-a-webview but i can implement in Pascal, i try to make a wrapper in lamw but is a hard function to start learning the lamw bridge, exits other method to obtain this information @jmpessoa  ? ---------------------------------------------------------------------- jmpessoa · 2020-08-16 00:43 Quoteit, i make some search on google and found https://stackoverflow.com/questions/8200945/how-to-get-html-content- from-a-webview Did you manage to draw any conclusions from this discussion... Quotei try to make a wrapper in lamw but is a hard function to start learning the lamw bridge... Do a Pascal function/method wrapper from an java API/method is very easy... [I can help...] In fact, LAMW generates the code for you! "Tools" -> "[LAMW]..." --> "New jComponent Create" --> [TAB] Help ---------------------------------------------------------------------- Segator · 2020-08-16 03:58 Hi jmpessoa, QuoteDid you manage to draw any conclusions from this discussion... yes, the only way to access to the html content is executing a javascript funcion to obtain the source and webview component support the EvaluateJavascript function but is no wrapper in the lamw component, QuoteDo a Pascal function/method wrapper from an java API/method is very easy... [I can help...]i try to do but the pascal code is not the problem, the java code is, i can send you the changes and you can help me where i mistake ---------------------------------------------------------------------- jmpessoa · 2020-08-16 04:35 Quote i can send you the changes and you can help me where i mistake  Ok. Send me, your java code! ---------------------------------------------------------------------- Segator · 2020-08-16 15:58 wheel this is the change in jWebView.java: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i public String callEvaluateJavascript(string _jscode){               this.evaluateJavascript(_jscode, new ValueCallback(){             @Override               public void onReceiveValue(String s){                    return s;               }        });        }And_jni_Bridge.pas: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  function jWebView_EvaluateJavaScript(env: PJNIEnv; _jwebview: JObject; _jscode:string):string;var  jParams: array[0..0] of jValue;  jMethod: jMethodID;  jCls: jClass;  _jString: jString;begin  jParams[0].l:= env^.NewStringUTF(env, PChar(_jscode));  jCls:= env^.GetObjectClass(env, _jwebview);  jMethod:= env^.GetMethodID(env, jCls, 'callEvaluateJavascript', '()S');  //env^.CallVoidMethodA(env, _jwebview, jMethod, @jParams);  _jString   := env^.CallObjectMethodA(env,_jwebview, jMethod, @jParams);  Result    := string( env^.GetStringUTFChars(Env,_jString,@jParams) );  env^.DeleteLocalRef(env, jParams[0].l);  env^.DeleteLocalRef(env, jCls);end;Laz_And_Controls.pas: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function jWebView.EvaluateJavascript(_jscode: string):string;begin  //in designing component state: set value here...  if FInitialized then     result:=jWebView_EvaluateJavaScript(FjEnv, FjObject, _jscode)  else   result:='';end;i attached the 3 files in a zip, i think that we must separate the onReceiveValue event ---------------------------------------------------------------------- Segator · 2020-08-16 18:20 I make some progress, some import java stuff is missing and other changes, now webview has the onReceiveValue event and the EvaluateJavascript method, the application build fine and run but when i call the EvaluateJavascript method it crash, i attached the changes. ---------------------------------------------------------------------- Segator · 2020-08-16 18:43 and this is my project example for test it, what i doing wrong? ---------------------------------------------------------------------- jmpessoa · 2020-08-17 03:50 Congratulations!!!! Done! Improved jWebView! New  Method "CallEvaluateJavascript" New   property/event     "OnEvaluateJavascriptResult" New demo "AppWebviewDemoEvaluateJavaScript" Thank you! ---------------------------------------------------------------------- Segator · 2020-08-17 12:02 Thanks to you jmpessoa, i learn viewing the changes in the code ---------------------------------------------------------------------- jmpessoa · 2020-08-17 19:25 Yes! And the LAMW can  generate the interface code for the  'native" event, too! ---------------------------------------------------------------------- Guser979 · 2020-09-13 09:49 I need to register my thanks here. This was very useful. Each day Lamw surprises me positively. Thanks Segator and JM. So far there has been no need to replace Lamw with Android Studio. I use Android Studio only for study and testing because I want to learn more about Java. ---------------------------------------------------------------------- jmpessoa · 2020-09-13 18:37 QuoteI use Android Studio only for study and testing because I want to learn more about Java. the doc is here:   [maybe you will need gradle 5.4.1 or +] https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/docs/Ho w_to_open_LAMW_project_with_AndroidStudio.txt Remember that AS don't like anymore this line [like] in Manifest: Quote So you will need drop this line! [and LAMW will reintroduce it when you reopen the project in another time...] PS.  In practice when I need improve/fix or create a new component I open my demo project in AS to edit/fix the java  side... ---------------------------------------------------------------------- Guser979 · 2020-09-13 20:27 I want to learn more about java precisely because of Lamw. In a few days using Lamw I was able to produce useful tools for work. I have little free time and Lamw was very productive. I believe that anyone who has had contact with pascal has no difficulty creating with Lamw. Thank you all.