How to automatically turn off an app after 10 minutes in background

Hello guys,

Is it possible to make an app automatically turn off itself once it’s been in background for 10 minutes?
For instance, even when you press android’s hardware home button, app will keep running in background. It will save the last status of app and will load that status once you turn it on again.
But I would like to completely shut it down after 10 mins.
How do you guys deal with this? Is there any cordova command for that?

Thanks,

Is this possible with native Android code?

1 Like

I have no idea but I have seen some native apps which restarts from beginning after being in background for a while. They will reload latest status of app for a while and then after 10 mins, it will load app from start with splash screen.

Ideally, it would be great to have “background control” plug-in which can control this behavior.
I will request this feature to Capacitor development team.

Maybe I will try:

if ( app is in background mode ) {
   setTimeOut ==> {
   exit(),
 600,000ms
}
}

Are you wanting this for Android/iPhone/Both?

For Android, I believe there’s a setting in the mainfest file to restart on re-entry. You can’t specify a time as far as I know though.

1 Like

It’s for android.

How does that setting look like? and how can I edit it?

I’ll not be developing for iOS until July this year.
I got seven android devices and will be digging android.