Recent

Author Topic: [SOLVED][Android] call external library with a string type in parameter ?  (Read 4389 times)

ROCABDEL

  • New Member
  • *
  • Posts: 41
I just did the test on the bass library, but I could not go too far ..
I happen to load the dll and initialize it, the problem is how to call a function with a "string" type..

ex:

in Bass.pas i:
 
Code: [Select]
BASS_StreamCreateFile      : function(mem: BOOL; f: Pointer; offset, length: QWORD; flags : DWORD): HSTREAM;
and in BASS.java i:
 
Code: [Select]
public static native int BASS_StreamCreateFile(String file, long offset, long length, int flags);
I called in the first BASS_StreamCreateFile with PChar(F) but the second I do not know how to call it.

Sorry for my English  :-[
thx
« Last Edit: June 17, 2012, 12:38:37 am by ROCABDEL »
Processor:IntelCore 2 2.19GHz - RAM 2GB
(Lazarus1.0.4 / fpc2.6.0 / qt4.7.3 at4pas2.5 / Xcode4.0)
-Windows 7/8-Intel Mac OS X 10.6.8-Haiku-Openidiana,Solaris11-PC-BSD,GhostBSD-openSUSE,Ubuntu,Fedora,mageia,Sabayon,Chakra..

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: [Android] call external library with a string type in parameter ?
« Reply #1 on: June 15, 2012, 10:23:57 am »
You can access Java APIs using JNI, I just added an example here:

http://wiki.freepascal.org/Android_Programming#Example_1:_Creating_a_Java_object_and_calling_a_Java_method

Try to use it as an example and build your own JNI code. If you have trouble then post here your partial JNI code and I will help you fix it and make it work.

ROCABDEL

  • New Member
  • *
  • Posts: 41
Re: [Android] call external library with a string type in parameter ?
« Reply #2 on: June 15, 2012, 10:28:23 am »
Ok thank you felipemdc  to answer so fast  :o
I will try Thx  ;D
Processor:IntelCore 2 2.19GHz - RAM 2GB
(Lazarus1.0.4 / fpc2.6.0 / qt4.7.3 at4pas2.5 / Xcode4.0)
-Windows 7/8-Intel Mac OS X 10.6.8-Haiku-Openidiana,Solaris11-PC-BSD,GhostBSD-openSUSE,Ubuntu,Fedora,mageia,Sabayon,Chakra..

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: [Android] call external library with a string type in parameter ?
« Reply #3 on: June 15, 2012, 11:52:45 am »
Yours is a bit different from my example, so I created a pseudo-code which might work explaining how to call static methods here:

http://wiki.freepascal.org/Android_Programming#Example_2:_Calling_a_static_method

ROCABDEL

  • New Member
  • *
  • Posts: 41
Re: [Android] call external library with a string type in parameter ?
« Reply #4 on: June 17, 2012, 12:37:29 am »
thank you it works, I think I understand now, the problem is resolved.
Thanks for the beautiful work you do, good continuation ...  ;)
Processor:IntelCore 2 2.19GHz - RAM 2GB
(Lazarus1.0.4 / fpc2.6.0 / qt4.7.3 at4pas2.5 / Xcode4.0)
-Windows 7/8-Intel Mac OS X 10.6.8-Haiku-Openidiana,Solaris11-PC-BSD,GhostBSD-openSUSE,Ubuntu,Fedora,mageia,Sabayon,Chakra..

 

TinyPortal © 2005-2018