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 130 forks source link

IONIC 5 with Capacitor facing to launch another app and get callback using startActivityForResult #134

Open veeravetrivel opened 2 years ago

veeravetrivel commented 2 years ago

I am using Ionic Angular with capacitor, we need to launch an external application which is our dependent application (Nativescript). With the ID of the app I need to launch and get callback once get image data. How to achieve this using Intent? Getting error block log in console ` const options = { action: this.webIntent.ACTION_GET_CONTENT, package: 'de.myapp.eco' /App package id in store installed in device / }

this.webIntent.startActivityForResult(options).then((onSuccess) => {
  console.log('onSuccess',onSuccess)
}).catch((error: any) => console.log('error',error));`

Can you please guide me out to achieve the result?

@darryncampbell @mcelotti @mattdsteele

darryncampbell commented 2 years ago

To invoke another application directly you can specify the component, please see https://github.com/darryncampbell/plugin-intent-api-exerciser/blob/master/www/js/index.js#L233 for an example

veeravetrivel commented 2 years ago

Thank you @darryncampbell , It works.

It opens the external application, But it closes of the source application. Any Idea how to make it without closing source application?

darryncampbell commented 2 years ago

it should just be invoking start activity, are you saying the calling app is being finish()'d?

veeravetrivel commented 2 years ago

Yes @darryncampbell for example 'A' app calls 'B' app, In this cased 'B' is opened but 'A' is closed. What I want is that 'A' app should be opened after B is closed. Hope you got it? How to achieve this using startActivityForResult?

darryncampbell commented 2 years ago

How to achieve this using startActivityForResult?

For StartActivityForResult example see https://github.com/darryncampbell/plugin-intent-api-exerciser/blob/master/www/js/index.js#L190. To return data from StartActivityForResult see https://github.com/darryncampbell/plugin-intent-api-exerciser/blob/master/www/js/index.js#L347 (this is test code to return from being invoked by https://github.com/darryncampbell/plugin-intent-api-exerciser-helper/blob/master/app/src/main/java/com/darryncampbell/pluginintentapiexerciserhelper/MainActivity.java#L24)