Delphi Android API 26 FileURIExposed

3

您好,我已经成功将我的 Delphi 应用程序升级到 API 26(当前使用 Rad Studio 10.1 Berlin),一切工作正常,但在 Android 6+ 设备上拍照时出现以下错误:

错误

这是我的代码:

procedure TF_SS_MAIN.ListBoxItem_menu_pictureClick(Sender: TObject);
var
  Service: IFMXCameraService;
  Params: TParamsPhotoQuery;
begin
  {$IFDEF Android}
  if TOSVersion.Check(6, 0) then
  begin
    try
      //Android 6+ stuff goes here, if basically I put the same code down below it crashes
    except
      on E: Exception do
        ShowMessage(E.Message);
    end;
  end
  else
  {$ENDIF}
  if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService, Service) then
  begin
    Params.Editable := true;
    // Specifies whether to save a picture to device Photo Library
    Params.NeedSaveToAlbum := false;
    // Params.RequiredResolution := TSize.Create(2736, 4864);
    Params.RequiredResolution := TSize.Create(2500, 2500);
    // Params.
    Params.OnDidFinishTaking := DoDidFinish;

    Service.TakePhoto(nil, Params);

    TabItem_picture.Visible := true;
    TabControl.ActiveTab := TabItem_picture;
  end
  else
    ShowMessage('This device does not support the camera service');
end;

3
当FireMonkey拍摄照片时,即使只是暂时存储,图像也必须保存到文件中。我猜FireMonkey用了file://来实现,但这种行为不再被允许,分享跨应用程序的文件必须使用FileProvider API。我不知道Tokyo或Rio是否修复了这个问题,但在Berlin中你可能无法得到修复,除非修改FireMonkey源代码或手动访问相机API。 - Remy Lebeau
2
Delphi Rio引入了对Android API 26的支持,据我所知它有一个使用FileProvider API的可工作的相机演示。 - Dalija Prasnikar
请参考“访问‘外部’URI”部分,链接如下:https://www.delphiworlds.com/2018/06/targeting-android-8-and-higher-continued/ - Dave Nottage
1个回答

1
似乎在10.1 Berlin中无法实现,我尝试了外部URI但不起作用,所以最好的情况是使用Remy Lebeau的建议,获取针对API 26+的10.3 Rio更新。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接