0

I have the following object in JavaScript that I capture from the console window:

Object
    action: "android.intent.action.SEND"
    clipItems: Array[1]
    component: "ComponentInfo{com.reunion.family/com.reunion.family.MainActivity}"
    extras: Object
        android.intent.extra.SUBJECT: "Adam Harris"
        android.intent.extra.TEXT: "http://www.adamwadeharris.com/setup-remote-debugging-phonegap/"
        share_screenshot_as_stream: "content://com.android.chrome.FileProvider/images/screenshot/1472164245526-1842859201.jpg"
        __proto__: —
    flags: 318767105
    type: "text/plain"
    __proto__: —

I can read the outer fields just find and the clipItems object without a issue. However the extras object I'm having a issue reading the "android.intent.extra.TEXT" and " android.intent.extra.SUBJECT" fields. the object that I wrote out to the console is called: intent

console.log(intent);

so I tried:

intent.android.intent.extra.TEXT
intent.extra.TEXT

but keep gettng a error message :

Error in Success callbackId: IntentPlugin1397752597 : TypeError: Cannot read property 'intent' of undefined

so i must be missing something.

any help would be great.

1 Answer 1

2

You can't use . to access a property name that isn't a valid identifier. Since the property name contains . characters, which are used as delimiters between nested properties, you can't use . to access the property itself. You have to use [] to access it.

intent.extras["android.intent.extra.SUBJECT"]
Sign up to request clarification or add additional context in comments.

4 Comments

shouldn't it be intent.extras["android.intent.extra.SUBJECT"]?
It's not clear what the variable intent contains. I guessed it was already pointing to the extras object, since he didn't use extras in any of his tries.
Oops, now I see that he said that intent is the object he wrote to the console.
@Barmar, Thank you that was it, and thank you for the nice explanation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.