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?