Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app is relaunched despite being open on android #348

Open
Earu opened this issue Sep 1, 2023 · 4 comments
Open

app is relaunched despite being open on android #348

Earu opened this issue Sep 1, 2023 · 4 comments

Comments

@Earu
Copy link

Earu commented Sep 1, 2023

So I've skimmed a bit through issues and read the doc, and I couldnt find a definite answer to this. On iOS if my app is already opened it will call the handler keeping the state of the app however on android it re-launches the app and then calls the handler.

This is kinda painful as im using the handler for an oauth process where I need a user to connect to an external webpage opened in the system browser and then redirected to the app using this plugin.

Is there any way to not re-launch the app and call the handler ? Or is this a bug ?

@davidhu3141
Copy link

It might be related to android platform's behavior, which is documented in cordova's platform guide. In your case, it's quite possible that the android system killed your MainActivity when you're opening another browesr, and then restored it afterwards.

If your test device is not that lack of resources, the problem does not happen everytime, is it?

@Earu
Copy link
Author

Earu commented Dec 12, 2023

It's been consistent, on both a physical test phone I have and a simulated pixel phone.

Is there any "easy" way to save state and restore it, maybe you know about this ? Because as far as I'm aware I'd have to save stuff to a file and read it again on resume, but the app is quite complex so this would be very tedious.

@davidhu3141
Copy link

To save the states, I just use JS local storage. Does that work for you?

Are there some other inconvenience that you encountered? I understand that at least your JS variables have lost. In my case the handleOpenURL was not called and I have to add

     <config-file target="res/xml/config.xml" parent="/*">
       <feature name="LaunchMyApp">
         <param name="android-package" value="nl.xservices.plugins.LaunchMyApp"/>
+        <param name="onload" value="true" />
       </feature>
     </config-file>

to plugin.xml's android part

@Earu
Copy link
Author

Earu commented Dec 12, 2023

Thanks that might help. And yeah my variables are lost, the View/Component/Page that the user had opened are also lost, inputs in forms, etc... All of this makes up to why its very tedious to save the state of the app.

I don't really have any other problem regarding this plugin otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants