Error on compiling Firemonkey Android APP

  

What is wrong with this code? Delphi 10.4 Compiler gives me

Not enough actual parameters

Error is on:
ServiceConnection.onServiceConnected := OnServiceConnected;

and
ServiceConnection.onServiceConnected := OnServiceConnected;

Here is the code:
unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.JavaTypes,
Androidapi.Helpers,
Androidapi.JNIBridge,
Androidapi.JNI.App,
Androidapi.JNI.Os,
FMX.Platform.Android,
FMX.Controls.Presentation, FMX.StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure OnServiceConnected(name: JComponentName; Binder: JIBinder);
procedure OnServiceDisconnected(name: JComponentName);
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.OnServiceConnected(name: JComponentName; Binder: JIBinder);
begin
//
end;

procedure TForm1.OnServiceDisconnected(name: JComponentName);
begin
//
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Intent: JIntent;
ServiceConnection: JServiceConnection;
begin
Intent := TJIntent.Create;
Intent.setPackage(StringtoJString(‘com.xxx.xxxservice’));
Intent.setAction(StringtoJString(‘com.xxx.xxxservice’));

ServiceConnection := TJServiceConnection.Create;
ServiceConnection.onServiceConnected := OnServiceConnected; // Not enough actual parameters !!!
ServiceConnection.onServiceDisconnected := OnServiceDisconnected; // Not enough actual parameters !!!
TAndroidHelper.Context.bindService(Intent, ServiceConnection, TJContext.JavaClass.BIND_AUTO_CREATE);
end;

end.

Comments are closed.