Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-04

demonstration of bug which do not allow javavcl users to call Android API functions

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mgr. Janusz Chmiel

Here is little example, which indicates why is it not possible to call Android API functions while using Java FVCL bundle

unit MainForm;
{$mode objfpc}
{$H+}
interface
uses _System, Classes, Controls, Dialogs, Forms, GenChars, LCLIntf,
Menus, StdCtrls, SysUtils, androidr22;
type
TFormMain = class(TForm)
PlayButton: TButton;
protected
procedure ButtonClick(A: TObject);
public
constructor Create(A: TComponent); override;
end;
var
FormMain: TFormMain;
jMediaPlayer1 : AOVibrator;
;
implementation
constructor TFormMain.Create(A: TComponent);
begin
inherited;
Caption := Application.Title;
PlayButton:= TButton.Create(Self);
PlayButton.Align := alTop;
PlayButton.Parent := Self;
PlayButton.Caption := 'Play live stream';
PlayButton.OnClick := @ButtonClick;
(*
*)
(*
*)
end;
procedure TFormMain.ButtonClick(A: TObject);
begin
if A = PlayButton then begin
jMediaPlayer1.vibrate(300);
end;
end;
end.

If you will compile this project and if you customize lovecalc project so this mainform.pas will be usable for you, you would get run-time error after running it on real Android device.
May be, that aactivity.pas which is The part of Pandroid bundle would solve this problem, but sure, whole Pascal project would had to be coded by using Mainactivity and not only Pascal form mode.