【问题标题】:Delphi Android API 26 FileURIExposedDelphi Android API 26 FileURIExposed
【发布时间】:2019-01-15 09:02:46
【问题描述】:

美好的一天, 所以我成功地将我的 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;

【问题讨论】:

  • 当 FireMonkey 拍摄相机照片时,即使只是暂时的,也必须将图像保存到文件中。我猜FireMonkey为此使用了file:// uri,并且不再允许这种行为,在跨应用程序共享文件时必须使用FileProvider API。我不知道东京或里约是否修复了这个问题,但如果不更改 FireMonkey 源代码或手动访问相机 API,您可能无法在柏林得到修复。
  • Delphi Rio 引入了对 Android API 26 和 AFAIK 的支持,它具有使用 FileProvider API 的有效相机演示。
  • 请参阅“访问“外部”URI”部分,此处:delphiworlds.com/2018/06/…

标签: android delphi firemonkey photo


【解决方案1】:

似乎在 10.1 Berlin 没有办法做到这一点,我尝试了外部 URi 但它不起作用,所以最好的情况是使用 Remy Lebeau 的建议并获得专门针对 API 26 的 10.3 Rio 更新+

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 2019-06-22
    • 1970-01-01
    • 1970-01-01
    • 2018-08-13
    相关资源
    最近更新 更多