cordova-plugin-background-mode icon indicating copy to clipboard operation
cordova-plugin-background-mode copied to clipboard

The app is "restarted" when I move it to background

Open Absant94 opened this issue 4 years ago • 3 comments

Hi! Im creating an app and I need to keep working in background but this doesnt work. I am on Visual studio with ionic, so I execute:

ionic cordova run android

The app is launched and working. The first view is a Login, I fill the login and this take me to the second view (that is a tab page). On this page I add:

constructor(private background: BackgroundMode){
this.background.enable();
console.log(this.background.isEnable());
console.log(this.background.isActive());
this.background.moveToBackground();
}

The problem is that when is moved to the background the app is "restarted". It means that when I open the app on background it takes me again to the first view where I should do the Login. So this is not working.

This image appears all the times that I open the app for background, and after this, the app is restarted

Am I doing something wrong? Is visual studio? How can I solve it?

Thanks!

Absant94 avatar Jul 15 '20 14:07 Absant94

Hi. Try it after moveToBackground()

this.backgroundMode.overrideBackButton()

elduglas avatar Jul 31 '20 13:07 elduglas

Could you try: https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background/src/master/

danielehrhardt avatar Sep 15 '20 14:09 danielehrhardt

I got the same situation, is there anyone who had solved this problem? Hope anyone can help me

taogogo avatar Feb 28 '21 06:02 taogogo