darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 134 forks source link

added Intent.EXTRA_KEY_EVENT support #73

Closed fquirin closed 5 years ago

fquirin commented 5 years ago

Code example:

window.plugins.intentShim.sendBroadcast({
        "action": "android.intent.action.MEDIA_BUTTON",
        "extras": {
            "android.intent.extra.KEY_EVENT": JSON.stringify({
                "action": 0,
                "code": 85
            })
        }
    },
    function() {
        console.log('Sent Android broadcast intent');
    },
    function() {
        alert('Failed to send Android broadcast intent')
    }
);

With: 0: KeyEvent.ACTION_DOWN 85: KEYCODE_MEDIA_PLAY_PAUSE

darryncampbell commented 5 years ago

Thanks. Ah yes, I see the extras value is interpreted as a string at https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/pull/73/files#diff-5c2f748b3052ee8ca0f98d6e2a506d26L535... there is probably room for improvement here but it is probably best to keep changes to a minimum and you have it working in your app so all is good. I will merge this pull request and push to npm.