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 I have this code in Delphi:
type
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;
When I do this in Delphi:
TJMyClass.JavaClass.init(StringToJstring('toto'), TAndroidHelper.Context.getApplicationContext);
I will receive this error:
Invoke error: method not found
if I rename init
to anything else (like initialize
, for example), it will work! But as it's not my library, I can not rename the function.
How can I call the init
function from Delphi?