Is there any way to automatically close the application after 'x' minutes of inactivity?

  1. Is there any way to automatically close an application after ‘x’ minutes of inactivity ?
  2. Is there any way to kill an activity, when the user minimizes an app (by pressing mobile menu/home button) and don’t use it even after ‘x’ minutes ?
  1. Yes. using the Clock function, However keeping the clock open during the entire application time can cause performance issues if it is not managed properly

  2. Yes you have a few options. Here are some blocks that might help.

I’m already having a problem (which I think is because of the clock component) and I couldnt solve it yet…

I will have a look at the other methods mentioned…

  • Create a global variable with false value
  • Start clock timer - 60 sec
  • Now change the global variable value to true if clock timer finished
  • Now check if global variable is true then exit the app.
    You can combine this with app resume and pause block too

I haven’t tested this method yet… So can’t tell if it’s working or not

Then how do we know if there’s an activity or not ? all my contents are on a single screen… and the other screen is a splash screen…

Global variable and timer will be useful here… Try to think of a solution by yourself… I already mentioned an alternative in the above comment… Never expect the complete answer… This way you will learn slowly… Try to do some experiment… Its kind of fun to experiment…

3 Likes