FMX TCameraComponent with IFMXCameraService bug

  

In the app I need to scan a Barcode, then access the camera to take photos followed by further Barcode scanning.
Therefore, I use both the TCameraComponent and IFMXCameraService interface.
The problem occurs once I start the TCameraComponent (for scanning a Barcode code), then deactivate it and take a photo… when i go back to TCameraComponent i get error: raised exception class EJNIException with message ‘java.lang.RuntimeException: getParameters failed (empty parameters)’.
An important clarification: if you first get a photo, and then open the barcode scanner, there is no error. The error appears if you open the barcode scanner at least once, close it, take a photo, and open the scanner again.
Start scanner:
if ( Length( AGrantResults ) = 1 ) and ( AGrantResults[ 0 ] = TPermissionStatus.Granted ) then
begin
SetCaptureSetting();
FBuffer.Clear( TAlphaColors.White );
FActive := True;
LabelFPS.Text := ‘Start capturing…’;
FCamera.Active := True;
StartStopWatch();
lblScanning.Text := ‘Scan On’;
FaLblScanning.Enabled := True;
end else
Showmessage( ” );

Stop scanner:
lblScanning.Text := ‘Scan Off’;
FaLblScanning.Enabled := False;
FActive := False;
DisplaySlowWarning(False);
FCamera.Active := False;
LabelFPS.Text := ”;

Take photo:
var
Params: TParamsPhotoQuery;
Service: IFMXCameraService;
begin
if TPlatformServices.Current.SupportsPlatformService( IFMXCameraService, Service ) then
begin
Params.Editable := False;
Params.NeedSaveToAlbum := False;
Params.RequiredResolution := TSize.Create( 1080, 1920 );
Params.OnDidFinishTaking := DoDidFinish;
Service.TakePhoto( btnTakePhoto, Params );
end else
ShowMessage(‘This device does not support the camera service’);

I tried making Service global, and using Service := nil after taking photo, did not help.

Comments are closed.