I need to create a function in my Android App that allows user to open the phone gallery, select more than one picture a time, then save the selected pictures in my local DB. What I need is the way to use Android Intent to get the selected pictures (files name and path). Hope you can understand my question.
I'm using this code:
if TPlatformServices.Current.SupportsPlatformService(IFMXTakenImageService,
IInterface(ImageService)) then
begin
Params.RequiredResolution := TSize.Create(640, 640);
Params.OnDidFinishTaking := DoDidFinish;
ImageService.TakeImageFromLibrary(SpeedButton2, Params);
end;
procedure TfGallery.DoDidFinish(Image: TBitmap);
begin
Image1.Bitmap.Assign(Image);
end;
Unfortunately this code can return one image a time from gallery.
Edit - Based on the answer of Nick Cardoso, the following code works for the first part of the problem:
Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_PICK);
intent.setType(StringToJString('image/*'));
intent.setAction(TjIntent.JavaClass.ACTION_GET_CONTENT);
Intent.putExtra(TJIntent.JavaClass.EXTRA_ALLOW_MULTIPLE,true);
LaunchActivity(Intent);
The code above works to select multiple pictures. Now I'm stuck to find a solution to get back (in a callback function) the selected files in Delphi!