Capacitor Browser plugin closes on Android app resume (under certain conditions) #3746
Unanswered
NicolasDupuyVA
asked this question in
Q&A
Replies: 1 comment
-
Did u ever find the answer? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm experiencing a weird behavior with the Capacitor Browser plugin on Android.
I created a sample app with "npx @capacitor/cli create" and added a button which opens a browser page :
On Android, when I click on this button, it opens the Browser on the requested URL. Then i move the app to background.
The weird behavior happens now :
Case 1 : If I bring the app back to foreground, by selecting it on the "list of running apps", Im taken back to the app, with the browser still opened.
Case 2 : If I bring the app back to foreground, by clicking on the app icon on my launcher, Im taken back to the app, BUT the browser is now closed.
What I saw while debugging is in case 1 the lifecycle events like "onResume" (on BridgeActivity and on Browser plugin) are not triggered, while in case 2 they are actually triggered, plus I'm receiving a "browserFinished" event.
Can someone help me find why and where in the code the browser is closed in case 2 (I need it to stay opened), and why is there different behaviours in flows that I think should behave the same way ?
Capacitor version : 2.4.2
Android version : 10
Thanks a lot !
EDIT 30/10 :
We have noticed that in case 1, the app is restarting, which is caused by the android:launchMode of MainActivity being "singleTask" (default for capacitor). When we change it to "standard" or "singleTop", it actually works as expected, Browser is not closed anymore.
BUT if we do this we encounter problems with deeplinks (no more working), and it seems to be the reason why launchMode was set to singleTask in the first place : see #971
So we still are stuck at the moment ... Any help would be appreciated. Thanks !
Beta Was this translation helpful? Give feedback.
All reactions