In an app, I select photos through the Android gallery. As I want to select multiple photos at once, I use the JIntent function. Now, it all works, and I want to load the selected photos into a TMSFMXtableview. For this, I need to convert the photos from JNet_Uri to TBitmap. What is the best way to do that?
This is the piece of code I want to use to load the photos into the TMSFMXtableview:
function TfmMain.OnActivityResult(RequestCode: Integer; ResultCode: Integer; Data: Jintent): Boolean;
var
I,count: Integer;
ImageUri : Jnet_Uri;
Fid : Integer;
bitmap : Tbitmap;
begin
Result := False;
TMessageManager.DefaultManager.Unsubscribe(TMessageResultNotification, FmessageSubscriptionID);
FmessageSubscriptionID := 0;
if requestcode=LibraryRequestCode then
begin
if ResultCode=TJActivity.JavaClass.RESULT_OK then
begin
if assigned(data) then
begin
Count := data.getClipData.getItemCount;
for I := 0 to count-1 do
begin
ImageUri := data.getClipData.getItemAt(i).getUri;
bitmap := //convert the imageuri to a Tbitmap
tv2.Items.Add;
FID := tv2.Items.Count-1;
tv2.Items.Items[FID].Bitmap.Assign(bitmap);
tv2.Items.Items[FID].Caption := 'NEW';
end;
end;
end
else
if ResultCode= TJActivity.JavaClass.RESULT_CANCELED then
begin
end;
result := true;
end;
end;