Android Question Intent GetExtras as a Map

Discussion in 'Android Questions' started by b4auser1, Mar 25, 2015.

  1. b4auser1

    b4auser1 Well-Known Member Licensed User

    Is there a way to get extra data from Intent as a Map ? It let to build more universal solutions without hardcoding getting each extra data Item with GetExtra("...").
     
    Troberg likes this.
  2. Troberg

    Troberg Well-Known Member Licensed User

    I'd find that useful as well, especially when exploring unknown/undocumented intents.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    For exploration you can use Log(Intent.ExtrasToString).
     
    Troberg likes this.
  4. b4auser1

    b4auser1 Well-Known Member Licensed User

    I need Map for Extras not for exploration, but for regular using in order to avoid hardcoding Extra Item names.
    Is there a way to do it with JavaObject ? If yes, I would appreciate the appropriate code snippet/
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It is not so simple. The keys are constants, they are supposed to be hardcoded.
     
  6. Troberg

    Troberg Well-Known Member Licensed User

    Nice, problem solved for me!
     
  7. b4auser1

    b4auser1 Well-Known Member Licensed User

    Is it possible to implement B4A ode using JavaObject see. below Java code ?

    Code:
    //fetching extra data passed with intents in a Bundle type variable
    extras = getIntent().getExtras();
    if(extras == null)
    {        newString= 
    null;
    }
    else
    {            /* fetching the string passed with intent using ‘extras’*/
    newString= extras.getString("STRING_I_NEED");
    }
    }
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    This is the same as calling Intent.GetExtra.
     
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