Для получения «content» я сделал так var
Intent: JIntent;
Uri: Jnet_Uri;
INStream: JInputStream;
OUTStream: JOutputStream;
outputfile: string;
FFF: JFile;
NumRead, NumWritten: Longint;
Buffer: TJavaArray<Byte>;
begin
...
Intent := SharedActivity.getIntent;
if (Pos('image/', JStringToString(Intent.getType))>0) or
(Pos('audio/', JStringToString(Intent.getType))>0) or
(Pos('video/', JStringToString(Intent.getType))>0) or
(Pos('application/', JStringToString(Intent.getType))>0) or
('*/*' = JStringToString(Intent.getType)) then
begin
if JStringToString(Intent.getType) <> '' then
begin
Parcel := Intent.getParcelableExtra(TJIntent.JavaClass.EXTRA_STREAM);
Uri := TJnet_Uri.Wrap(Parcel);
if JStringToString(Uri.getScheme) = 'content' then
begin
if Pos('/mpeg', JStringToString(Intent.getType)) > 0 then
outputfile := 'my.mp3'
else
if Pos('/jpeg', JStringToString(Intent.getType)) > 0 then
outputfile := 'my.jpg'
else
outputfile := 'my.' + copy(JStringToString(Intent.getType), Pos('/', JStringToString(Intent.getType))+1,
Length(JStringToString(Intent.getType)));//выдергиваем имя типа для того чтобы сделать его расширением
//на случай если в Intent не уточнен тип, а указана *, например image/*
if Pos('.*', outputfile) > 0 then
outputfile := StringReplace(outputfile, '.*', '.tmp', [rfReplaceAll]);
Buffer := TJavaArray<Byte>.Create(4096);
INStream := SharedActivityContext.getContentResolver.openInputStream(Uri);
try
FFF := TJFile.JavaClass.init(StringToJString(<ИМЯ_ПАПКИ>), StringToJString(outputfile));
FFF.setWritable(true, false);
OUTStream := TJFileOutputStream.JavaClass.init(FFF);
repeat
NumRead := inStream.read(buffer);
if (NumRead <= 0) then
Break;
outStream.write(buffer, 0, NumRead);
application.ProcessMessages;
until NumRead <= 0;
outStream.close;
inStream.close;
except
on e: exception do
raise Exception.CReate('Error. Can''t copy file');
end;
end
end
end
end
может не самое оптимальное, но работает, в итоге у вас файл с именем outputfile и в папке <ИМЯ_ПАПКИ>