How to record sound in the background in android using Delphi 10

  

Hell, I am trying to test Delphi 10 Android background services, i am trying to record sound in the background using local service,however, when the service starts its dosent recored sound to Test.caf , my codes :
the App

procedure TForm1.Button1Click(Sender: TObject);
begin
TLocalServiceConnection.StartService(‘RecService’);

The service code :

function TAndroidServiceDM.AndroidServiceStartCommand(const Sender: TObject;
const Intent: JIntent; Flags, StartId: Integer): Integer;
begin
Result := TJService.JavaClass.START_STICKY;
FMicrophone := TCaptureDeviceManager.Current.DefaultAudioCaptureDevice;

{ and attempt to record to ‘test.caf’ file }
FMicrophone.FileName := ‘/sdcard/1/test.caf’;
FMicrophone.StartCapture;
sleep(5000);
FMicrophone.StopCapture;

any help appreciated many thanks.

Comments are closed.