[fpc-pascal] JNI/Android: Java events calling pascal code
patspiper at gmail.com
Tue Apr 22 18:39:44 CEST 2014
On 22/04/14 19:26, leledumbo wrote:
>> Now to the java media player: You assign a pascal method to the
> OnCompetion event (the question is how), and start the player
> (pascal/jni). Once the song is over, OnCompletion will fire and call the
> assigned pascal method.
> Ah... I see. That is AFAIK not possible. Java doesn't have the procedural
> type concept as it has much more OOP forced. Common Java code for callback
> is to pass an anonymous inner class implementing expected interface. The
> problem is that AFAIK JNI doesn't have access to dynamic class creation like
> that, you will need to write a Java wrapper which implements the interface
> and assign the Pascal callback.
So there is no way out without java coding. Moreover, each jclass that
has 'events' will need a wrapper class.
However, it seems there might be a better solution which uses a fixed
java snippet for all classes (using a dynamic proxy). As I am not very
involved with java, pls have a look at:
especially the post before the last. Maybe you can shed more light on this?
More information about the fpc-pascal