在 Delphi 11.3 中,你可以使用 'TReceiveIntentAction' 组件接收共享文件。以下是具体步骤:

  1. 在你的 Delphi 11.3 项目中添加一个 'TReceiveIntentAction' 组件。

  2. 右键单击 'TReceiveIntentAction' 组件,选择 'Edit Intents'。

  3. 在 'Intents' 窗口中,添加一个新的 Intent,并设置 'Action' 为 'android.intent.action.SEND' 和 'Type' 为 '/'。

  4. 在 'TReceiveIntentAction' 组件的 'OnReceiveIntent' 事件中,添加代码来处理接收到的文件。可以使用 'Intent.Extras' 来获取传递的数据,例如:

procedure TForm1.ReceiveIntentAction1ReceiveIntent(Sender: TObject;
  const AIntent: JIntent);
var
  Uri: Jnet_Uri;
  FileName: string;
begin
  if AIntent.getAction.equals(TJIntent.JavaClass.ACTION_SEND) then
  begin
    Uri := AIntent.getParcelableExtra(TJIntent.JavaClass.EXTRA_STREAM);
    if Assigned(Uri) then
    begin
      FileName := JStringToString(Uri.getLastPathSegment);
      // 处理接收到的文件
    end;
  end;
end;
  1. 运行你的应用程序,并从另一个应用程序中共享一个文件,例如通过文件管理器发送文件。

  2. 你的应用程序将收到一个 Intent,然后就可以处理接收到的文件了。

Delphi 11.3 Android 接收共享文件

原文地址: https://www.cveoy.top/t/topic/n6zx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录