我尝试集成到 Delphi appsFlyer (android)
public abstract interface AppsFlyerConversionListener
{
@WorkerThread
public abstract void onInstallConversionDataLoaded(Map<String, String> paramMap);
public abstract void onInstallConversionFailure(String paramString);
@WorkerThread
public abstract void onAppOpenAttribution(Map<String, String> paramMap);
public abstract void onAttributionFailure(String paramString);
}
public class AppsFlyerLib implements a
{
public static AppsFlyerLib getInstance() {...}
public AppsFlyerLib init(String paramString, AppsFlyerConversionListener paramAppsFlyerConversionListener) {...}
public AppsFlyerLib init(String paramString, AppsFlyerConversionListener paramAppsFlyerConversionListener, Context paramContext) {...}
}
所以我像这样在delphi中翻译这些类:
{*******************************************************}
JAppsFlyerConversionListenerClass = interface(IJavaClass)
['{FE22E5D8-EF6E-44DE-AE27-45C224FF4E06}']
end;
{**********************************************************}
[JavaSignature('com/appsflyer/AppsFlyerConversionListener')]
JAppsFlyerConversionListener = interface(IJavaInstance)
['{698F89B7-7DD7-4F32-B196-BEE4E16FBD36}']
procedure onAppOpenAttribution(conversionData: JMap); cdecl;
procedure onAttributionFailure(errorMessage: JString); cdecl;
procedure onInstallConversionDataLoaded(conversionData: JMap); cdecl;
procedure onInstallConversionFailure(errorMessage: JString); cdecl;
end;
TJAppsFlyerConversionListener = class(TJavaGenericImport<JAppsFlyerConversionListenerClass, JAppsFlyerConversionListener>) end;
{****************************************}
JAppsFlyerLibClass = interface(IJavaClass)
['{B2787D1A-BDFB-41A3-B876-05148C26FF3F}']
{class} function getInstance: JAppsFlyerLib; cdecl;
end;
{*******************************************}
[JavaSignature('com/appsflyer/AppsFlyerLib')]
JAppsFlyerLib = interface(IJavaInstance)
['{F8676840-7A1B-4BA7-BFFD-362668E9927A}']
function init(key: JString; conversionListener: JAppsFlyerConversionListener): JAppsFlyerLib; cdecl; overload;
function init(key: JString; conversionListener: JAppsFlyerConversionListener; context: JContext): JAppsFlyerLib; cdecl; overload;
end;
TJAppsFlyerLib = class(TJavaGenericImport<JAppsFlyerLibClass, JAppsFlyerLib>) end;
我像这样实现 JAppsFlyerConversionListener :
TAppsFlyerConversionListener= class(TJavaLocal, JAppsFlyerConversionListener)
private
public
procedure onAppOpenAttribution(conversionData: JMap); cdecl;
procedure onAttributionFailure(errorMessage: JString); cdecl;
procedure onInstallConversionDataLoaded(conversionData: JMap); cdecl;
procedure onInstallConversionFailure(errorMessage: JString); cdecl;
end;
但现在当我打电话时:
FAppsFlyerConversionListener := TAppsFlyerConversionListener.create;
TJAppsFlyerLib.JavaClass.getInstance.init(StringToJstring('xxxxx'), FAppsFlyerConversionListener, TAndroidHelper.Context.getApplicationContext);
我收到 :
调用错误:找不到方法
知道为什么吗?
注意:即使TJAppsFlyerLib.JavaClass.getInstance.init(nil, nil, nil)
返回我
调用错误:找不到方法
注意2:我不知道这是否重要,但我们也有以下init
功能JObjectClass
:
JObjectClass = interface(IJavaClass)
['{83BD30EE-FE9B-470D-AD6C-23AEAABB7FFA}']
{class} function init: JObject; cdecl;
end;