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:
    Code:
    shortcutIntent.SetType("image/*")
    shortcutIntent.PutExtra(
    "android.intent.extra.STREAM"image.bmp)
    (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:
    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 "extra.stream". 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:
    Code:
    Dim LotsaStuff() As Object = Array As Object(ExtraPicture, ExtraSound, ExtraVideo)

    shortcutIntent.SetType(
    "image/*")
    shortcutIntent.PutExtra(
    "android.intent.extra.STREAM", LotasStuff)
    and then on the receiving side:
    Code:
    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.
Loading...
  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