bcvs 0 Posted July 29 Hi, I have to use an .jar file in my Android App. I've already created this bridge file and added the .jar as library as explained here: http://docwiki.embarcadero.com/RADSt...o_Android_Apps So far everythis is OK. Now I'm about to use the classes in my App. To start and to get into it I wand to call the function isNfcEnabled. The corresponding class looks like this in the bridge file: JCardlinkClass = interface(JICardlinkCallbackClass) ['{62BD9E24-88F0-4FD3-BD57-65479E39241E}'] {class} function _GetINSTANCE: JCardlink; cdecl; {class} function getDebug: Boolean; cdecl; {class} function getLogLevel: JLogLevel; cdecl; {class} function getSmsHack: Boolean; cdecl; {class} function getState: JCardlinkState; cdecl; {class} procedure initialize(string_: JString; iCardlinkCallback: JICardlinkCallback; string_1: JString; string_2: JString); cdecl; {class} function isNfcEnabled(context: JContext): Boolean; cdecl; {class} function isNfcHardwareAvailable(context: JContext): Boolean; cdecl; {class} procedure requestSmsToken(string_: JString; string_1: JString; string_2: JString; string_3: JString); cdecl; {class} procedure setDebug(b: Boolean); cdecl; {class} procedure setLogLevel(logLevel: JLogLevel); cdecl; {class} procedure setSmsHack(b: Boolean); cdecl; {class} procedure shutdown; cdecl; {class} procedure startScan(string_: JString; activity: JActivity); cdecl; {class} procedure verifySmsToken(string_: JString); cdecl; {class} property INSTANCE: JCardlink read _GetINSTANCE; end; [JavaSignature('de/...../Cardlink')] JCardlink = interface(JICardlinkCallback) ['{46B08D27-AA20-4A0D-971E-7405E46E0787}'] procedure onError(cardlinkError: JCardlinkError; string_: JString; cardlinkAction: JCardlinkAction); cdecl; procedure onPrescriptionBundles(list: JList); cdecl; procedure onPrescriptionTokens(string_: JString); cdecl; procedure onProgressUpdate(i: Integer); cdecl; procedure onStateChanged(cardlinkState: JCardlinkState); cdecl; end; TJCardlink = class(TJavaGenericImport<JCardlinkClass, JCardlink>) end; I think I have to create an instance of JCardlink first. What I tried: var CardLink: TJCardlink; CardLink:=TJCardlink.JavaClass.INSTANCE; // <-- Incompatible Types TJCardlink und JCardlink CardLink.JavaClass.isNfcEnabled(context); var CardLink: TJCardlink; CardLink:=TJCardlink.Create; // <-- Incompatible Types TJCardlink und JCardlink CardLink.JavaClass.isNfcEnabled(context); var CardLink: JCardlink; CardLink:=TJCardlink.JavaClass.INSTANCE; CardLink.JavaClass.isNfcEnabled(context); // <-- unknown identifier JavaClass CardLink.isNfcEnabled(context); // <-- unknown identifier isNfcEnabled It seems that I can only create an instance of JCardlink. But isNfcEnabled is a member of JCardlinkClass or TJCardlink.JavaClass. How can I get this together? Share this post Link to post
Dave Nottage 557 Posted July 29 3 hours ago, bcvs said: CardLink.JavaClass.isNfcEnabled(context); This should be: if TJCardLink.JavaClass.isNfcEnabled(context) then // Take whatever action needed if NFC is enabled Share this post Link to post
bcvs 0 Posted July 30 Thank you, that works. I was wrong when I thought, that I had to create in instance on TJCardlink as in this case it is a singleton. Share this post Link to post
Rollo62 536 Posted August 7 CrossPost https://www.delphipraxis.net/1539305-post6.html I thought this basic question was clarified already here 🤔 Share this post Link to post