Android Question How to insert and extract mutliple file/types in an intent

Discussion in 'Android Questions' started by JohnC, Aug 25, 2019.

  1. JohnC

    JohnC Well-Known Member Licensed User

    I am currently embedding an image ("stream") into an intent that is used to create a new shortcut using this code:
    (note: I need to embed the actual file data into the intent and not a uri reference because of various project requirements)

    Then when the shortcut is used to launch my app, I extract the image data using this code:
    Dim r As Reflector
    r.Target = StartIntent
    Dim bmp As Bitmap = r.RunMethod2("getParcelableExtra""android.intent.extra.STREAM""java.lang.String")
    But I would also like to add a sound file (.wav) into the same intent, so how could I embed both media files/types into the same intent?

    I ask because the ".SetType("image/*")" method and the "PutExtra("android.intent.extra.STREAM") method don't seem to have any type of "index" parameter to specify which "Settype" is associated with each "". So, it gives me the impression that you can only embed one media/file in an intent.

    Is there a way I can embed multiple media types and/or multiple files (of the same media type), and then how would I extract each one?
  2. emexes

    emexes Well-Known Member Licensed User

    Does using a (single) List or Array of multiple Extras work?

    eg something like:
    Dim LotsaStuff() As Object = Array As Object(ExtraPicture, ExtraSound, ExtraVideo)

    "android.intent.extra.STREAM", LotasStuff)
    and then on the receiving side:
    Dim r As Reflector
    r.Target = StartIntent
    Dim LotsaStuff() As Object = r.RunMethod2("getParcelableExtra""android.intent.extra.STREAM""java.lang.String")    'presumably .String should be .Array or similar
    Dim bmp as Bitmap = LotsaStuff(0)
    Shelby likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice