darryncampbell-cordova-plugin-intent icon indicating copy to clipboard operation
darryncampbell-cordova-plugin-intent copied to clipboard

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

Open veeravetrivel opened this issue 3 years ago • 5 comments

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

veeravetrivel avatar Oct 20 '21 13:10 veeravetrivel

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

darryncampbell avatar Oct 20 '21 14:10 darryncampbell

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?

veeravetrivel avatar Oct 21 '21 09:10 veeravetrivel

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

darryncampbell avatar Oct 21 '21 12:10 darryncampbell

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?

veeravetrivel avatar Oct 21 '21 12:10 veeravetrivel

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)

darryncampbell avatar Oct 21 '21 16:10 darryncampbell