Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – Handling intent result of multiple selected files from the storage

Posted on November 14, 2022

Solution 1 :

I found a solution. Here you go:

// loop through all images
JStringToString(Data.getClipData.getItemAt(i).getUri.toString

Problem :

I have this headache with android Intents. i’m trying to select multiple image from the storage. i made it work till the point to handle the results. my guess is that some sort of For loop of get the path of all files?. The Result in my code returns empty, i don’t know what is the problem. my code so far :

//Button to launch activity : 
var
  Intent: JIntent;
begin
  FMessageSubscriptionID :=
    TMessageManager.DefaultManager.SubscribeToMessage
      (TMessageResultNotification, HandleActivityMessage);

  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);
  SharedActivity.startActivityForResult(Intent, 0);
end;

//Handling Result : 
procedure HandleActivityMessage(const Sender: TObject; const M:   TMessage);
function OnActivityResult(RequestCode, ResultCode: Integer; Data: JIntent): Boolean;

...

procedure TForm3.HandleActivityMessage(const Sender: TObject; 
const M: TMessage);
begin
  if M is TMessageResultNotification then
   OnActivityResult(TMessageResultNotification(M).RequestCode, 
     TMessageResultNotification(M).ResultCode,
     TMessageResultNotification(M).Value);
end;

function TForm3.OnActivityResult(RequestCode, ResultCode: Integer;
      Data: JIntent): Boolean;
var
  filename : string;  list : Tstrings;
begin
   Result := False;
   TMessageManager.DefaultManager.Unsubscribe(
      TMessageResultNotification, FMessageSubscriptionID);
   FMessageSubscriptionID := 0;
         
   if RequestCode = ScanRequestCode then
   begin
     if ResultCode = TJActivity.JavaClass.RESULT_OK then
     begin
       if Assigned(Data) then
       begin
         // 
         filename := JStringToString(
                Data.getStringExtra(
                  StringToJString('RESULT'))
              );
         filename := JStringToString(
                Data.getStringExtra(
                  TJIntent.JavaClass.EXTRA_TEXT
                )
                );
        ShowMessage('Result : '+filename);
        memo1.Lines.Add(filename);
      end;

      Toast(Format(
       'Found %s format barcode:'#10'%s', [ScanFormat,
         ScanContent]), LongToast
       );
    end;
  end
  else if ResultCode = TJActivity.JavaClass.RESULT_CANCELED then
  begin
    ShowMessage('No');
  end;
Result := True;

end;
end;

used IDE : Delphi 10.3.3 and Android 9

READ  [ANSWERED] java - When I rotate the screen, the fragment is destroyed and returned to Activity, which opened that Fragment. But why he's doing so?
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress