Android Question How do I access Intent.getParcelableExtra?

NeoTechni

Well-Known Member
Licensed User
Longtime User
I am attempting to broadbast Bitmaps generated by one app to another.
I am doing this so all the coded needed to generate the Bitmap is not needed in the destination app, to reduce bloat. I do not want to save the Bitmaps as files cause that puts unwanted strain on the SD card

When I looked it up, Intent.getParcelableExtra will allow me to get the Bitmap from a broadcast intent, how would I use a reflection object to call that since it's not available in the StartingIntent object?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
I found the code to get the BMP from the bytearray

B4X:
Sub GetBitmapFromByteArray(picBuffer() As Byte ) As Bitmap
  Try
      Dim InputStream1 As InputStream, Bitmap1 As Bitmap
      InputStream1.InitializeFromBytesArray(picBuffer, 0, picBuffer.Length)
      Bitmap1.Initialize2(InputStream1)
      InputStream1.Close
      Return Bitmap1
  Catch
      Return Null
  End Try
End Sub

How would I do the reverse?
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
B4X:
Sub GetByteArrayFromBitmap(BMP As Bitmap) As Byte()
    Dim Output As OutputStream
    Output.InitializeToBytesArray(bmp.Width * bmp.Height )
    BMP.WriteToStream(Output, 100, "PNG")
    Return Output.ToBytesArray
End Sub
I will test this.
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
That worked but...

I am making a launcher, and to receive make shortcut intents, I need to be able to get the BMP out of an intent the regular way
 
Upvote 0
Top