Hi Folks,

In my mobile application I would like to calculate / know idle time i.e. where the user did not touch to app screen or could gone into sleep mode. 

Is there any background process by which we can get idle time?

Kindly provide the solution for the same.

Thanks


Solution

You could use a handler for the ontouchstart event (simular to the onclick event).

The quick way would be to use a global variable where you store the last touch time, you update this value in the touch handler. 

Then whenever you need the value for something (display perhaps?) you can just read out this variable.

https://www.w3schools.com/jsref/obj_touchevent.asp


You could also take a look at this snippet:

https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/

You'll might have to adjust it for mobile events though.

Solution

Joey Moree wrote:

You could use a handler for the ontouchstart event (simular to the onclick event).

The quick way would be to use a global variable where you store the last touch time, you update this value in the touch handler. 

Then whenever you need the value for something (display perhaps?) you can just read out this variable.

https://www.w3schools.com/jsref/obj_touchevent.asp


You could also take a look at this snippet:

https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/

You'll might have to adjust it for mobile events though.

Thanks Joey Moree,

I got the hint from your solution post and I can implement it using javaScripts (Y)



Joey Moree wrote:

You could use a handler for the ontouchstart event (simular to the onclick event).

The quick way would be to use a global variable where you store the last touch time, you update this value in the touch handler. 

Then whenever you need the value for something (display perhaps?) you can just read out this variable.

https://www.w3schools.com/jsref/obj_touchevent.asp


You could also take a look at this snippet:

https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/

You'll might have to adjust it for mobile events though.

So Outsystems itself does not provide any method to detect mobile app states? 


Joachim Leow wrote:

Joey Moree wrote:

You could use a handler for the ontouchstart event (simular to the onclick event).

The quick way would be to use a global variable where you store the last touch time, you update this value in the touch handler. 

Then whenever you need the value for something (display perhaps?) you can just read out this variable.

https://www.w3schools.com/jsref/obj_touchevent.asp


You could also take a look at this snippet:

https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/

You'll might have to adjust it for mobile events though.

So Outsystems itself does not provide any method to detect mobile app states? 


There's no default action I'm afraid, I think you can use some phonegap events to check if the app becomes active (by going to the foreground).