[fpc-pascal] JNI/Android: Java events calling pascal code

patspiper patspiper at gmail.com
Tue Apr 22 11:52:46 CEST 2014


On 22/04/14 12:02, leledumbo wrote:
>> My question is whether it is possible to hook
> into (as an example) the java media player events without writing java
> code. As for the opposite direction, calling the media player's Start
> method from pascal does not need any java code.
>
> If it can be done from C, then it can be done from Pascal as well. In fact,
> the Java compiler frontend is written in C, which initializes JVM and then
> call the Java compiler (which is written in Java). The problem now is that
> you will have to initialize JVM yourself (which I don't have experience in)
> and interact with the existing Java code from Pascal through JNI.

I can already launch the android media player from pascal using JNI 
(without any java code), and I don't think there is a problem handling 
the player's events IF a java wrapper class that intercepts the player's 
events and calls native (pascal) methods is implemented.

My question is if it can be done without a java wrapper class as this 
would make android programming much easier (unless I have misunderstood 
your reply).

Stephano



More information about the fpc-pascal mailing list