Jump to content
Juan Felix

How to read Stream(Image) from Parcelable?

Recommended Posts

I tried to create Androdi App to send from another android app when share Text and Image.

 

function TForm1.HandleIntentAction(const Data: JIntent): Boolean;
var
  Extras: JBundle;
begin
Result := False;
if Data <> nil then
  begin
  Memo1.ClearContent;
  Extras := Data.getExtras;
  if Extras <> nil then
    begin
    Edit1.Text := JStringToString(Extras.getString(TJIntent.JavaClass.EXTRA_SUBJECT));
    Memo1.Text := JStringToString(Extras.getString(TJIntent.JavaClass.EXTRA_TEXT));
    var
    datastream := Extras.getParcelable(TJIntent.JavaClass.EXTRA_STREAM);
    ///
    /// I don't know how to use the variable datastream above to get the filename, so... i can read it to TBitmap
    ///
    Memo3.Text := JStringToString(Extras.toString);
    ///
    /// From the code above, I got the text like this:
    ///
    /// Bundle[{
    /// android.intent.extra.SUBJECT=Ms Glow Jateng - Ms Glow Ultimate Night Cream,
    /// android.intent.extra.TEXT=Ms Glow Jateng - Ms Glow Ultimate Night Cream
    ///
    /// ULTIMATE NIGHT CREAM adalah cream malam yang diperuntukkan bagi tipe jenis kulit yang memiliki flek/bernoda hitam bekas ...
    ///
    /// Yuk beli sekarang!
    /// Harga: Rp85.000 Rp72.250
    /// https://berikhtiar.com/juan.249/product/ms-glow-jateng-ms-glow-ultimate-night-cream,
    /// android.intent.extra.STREAM=content://evermos.evermos.com.evermos.flutter.share_provider/cache/b74a99e1-b56d-49af-b072-e075f392e0ef.png}]
    ///
    end;
  Invalidate;
  end;
end;

 

Share this post


Link to post

try some like this:

procedure TForm1.Button1Click(Sender: TObject);
var
  LIntent    : JIntent;
  LString    : JString;
  LParcelable: JParcelable;
  LURI       : JNet_Uri;
begin
  LString := LIntent.getExtras.getString(TJIntent.JavaClass.EXTRA_STREAM);
  //
  LParcelable := LIntent.getExtras.getParcelable(LString);
  LURI        := TJnet_Uri.Wrap(LParcelable);
  LURI.getXXXXX;
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×