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

Support to Android <= 7 #81

Closed gabrielvoigt closed 4 years ago

gabrielvoigt commented 4 years ago

The scenario is that I need to make a service that returns success or error from the Moove QLY application. When I'm trying to use startActivityForResult, look:

window.plugins.intentShim.startActivityForResult({
                        action: window.plugins.intentShim.ACTION_PICK,
                        component: {
                            package: 'pt.sibs.android.mpos.bcpqly',
                            class: 'pt.sibs.android.mpos.activities.MainActivity'
                        },
                        extras: {
                            "DATA_MPOS": {
                                "PACKAGE_ID": "pt.sibs.android.callmPos",
                                "RETURN_VALUE_BOOLEAN": true,
                                "BASE64REFERENCE": encodedData,
                                "REQUEST_KEY": 100
                            }
                        },
                        flags: [536870912],
                        requestCode: 100
                    },
                    function(intent) {

For Android 7 and 6, the intent return this:

{"extras":{"resultCode":0,"requestCode":100},"flags":0}".

However, Android 8 return this:

{"resultCode":-1, CALL_IN_STATUS : "UserCancelled", "requestCode":100}"

I need to get a result equal to android 8.

darryncampbell commented 4 years ago

So the application being invoked via StartActivityForResult uses this plugin? You can set the result as follows:

window.plugins.intentShim.sendResult(
            {
                extras: {
                    'Test Intent': 'Successfully sent',
                    'Test Intent int': 42,
                    'Test Intent bool': true,
                    'Test Intent double': parseFloat("142.12")
                }
            },
            function()
            {

            }
        );
darryncampbell commented 4 years ago

Closing due to inactivity