On 25/04/14 00:12, Felipe Monteiro de Carvalho wrote:
There is a JNI example app here:
http://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android-ndk/examples/jnitest/

It doesn't create a button, instead it creates a TextView, and it
doesn't create it in Pascal, but in Java. Anyway, it is a starting
point to do whatever you want, including creating buttons in Pascal.


Thanks.

I had already progressed but stopped at setContentView. Since I am using LazAndroidModuleWizard to kickstart, it seems I can't use that method, especially that the code that creates the button is called from the main data module. I am trying to find how to "inject" the button into the datamodule.

If the concept works, then the workflow of creating an android app with Lazarus would be:

- Use a project wizard to setup the project. It will place a fixed java snippet in the src project folder and set up manifest files and ancillary files.

- Run a tool which reads android "headers" and produces a pascal unit(s) according to certain rules.

- Code in pascal :)

The tool will produce for each java class a corresponding pascal class. For example, the pascal android media player class will be analogous to the java one, but acts as a gateway to the actual java class. It uses normal pascal events instead of listeners.

example code for the media player:
  gMediaPlayer := TJMediaPlayer.Create;
  ....
  gMediaPlayer.SetOnCompletionListener(DataModuleOnCompletion);
  gMediaPlayer.SetOnPreparedListener(DataModuleOnPrepared);
gMediaPlayer.SetDataSource('http://www.soundjay.com/button/button-1.mp3');
  gMediaPlayer.Prepare;
  gMediaPlayer.Start;
  ...
  gMediaPlayer.Free;

DataModuleOnCompletion and DataModuleOnPrepared are normal pascal methods (TNotifyEvent in this case).

Stephano
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to