Delphi + android java class + init function

  

following my previous question (Why I receive Invoke error: method not found), I found a problem and want to make it as a new standalone question

I have this class in java:

public class myClass {

public static void init(String key, Context context) {}

}

and in Delphi I have:

JMyClassClass = interface(JObjectClass)
[‘{2E91BB84-D9C9-4569-A687-BCB3684A8DBD}’]
{class} procedure init(key: JString; context: JContext); cdecl;
end;

[JavaSignature(‘com/myClass’)]
JMyClass = interface(JObject)
[‘{2761621D-63E1-4F57-964D-46FBE81DAB8B}’]
end;
TJMyClass = class(TJavaGenericImport<JMyClassClass, JMyClass>) end;

then when i will do in delphi

TJMyClass .JavaClass.init(StringToJstring(‘toto’), TAndroidHelper.Context.getApplicationContext);

i will receive

Invoke error: method not found

if i rename init to anything else (like initialize for exemple) then it’s will work ! but as it’s not my library i can not rename the function

so how can i call the init function from delphi ?

Comments are closed.