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

Open app in independent tab #46

Closed psonawane-servicetitan closed 6 years ago

psonawane-servicetitan commented 6 years ago

Hi, Is there a way we can open the app in independent tab? Currently, when I start a new activity, the new app is opening inside my current app. I want it to open in different tab, so that I see two separate windows(old app and currently opened app) in task manager. Currently, I see only one window in task manager.

Thanks, Pooja

psonawane-servicetitan commented 6 years ago

I found that if in IntentShim.java in populateIntent() , if I replace Intent i = new Intent(); by final PackageManager pm = this.webView.getContext().getPackageManager(); Intent i = pm.getLaunchIntentForPackage(packageAssociated);

It creates a new window for second app. Am I doing it correct? If so, can you please update this in your plugin too? Or is there some other way to do the functionality that I want?

darryncampbell commented 6 years ago

I think you want to specify the singleTop flag, you can pass in an array of flags when you specify the intent (https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/commit/b22421d3fef74a6b724af93115d9606975eecf8a). You need to specify the integer value for the flag, https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_SINGLE_TOP which is 536870912

nero120 commented 4 years ago

@darryncampbell I'm having the same issue but I don't fully understand your answer here.

In my case, my app receives an intent when a user shares a url from a browser (e.g. Chrome). My app's main activity starts in the same task window as the browser and I get the intent info using your getIntent function. I would like my application to start in it's own task window if possible.

From what you say above, do I need to run 'startActivity' instead of getIntent passing the flag value for singleTop? Many thanks for your plugin and your help!