How to check is app is in the background or foreground

Hi ,

I need to check app is in the background or foreground, based on that i need to perform some action when user enters into my application, so for that i am trying with javascript in On Ready event with below code 

document.addEventListener("resume",OnResume,false);

and in On Destroy event i am writing below code 

document.removeEventListener("resume",OnResume,false);

after running the above code in device it is giving me the follwing error OnResume is not defined, is this right way to do to get the resume of the app in outsystems.


Thanks

Harish


Hello Harish,


Have you tried onResume instead of OnResume?


Best regards

Hi Cristiano,

Tried with both onResume and OnResume , but i am unable to receive any update when i am locking and unlocking or using other app and coming to current app it is not calling this action.

Cristiano Marques wrote:

Hello Harish,


Have you tried onResume instead of OnResume?


Best regards


Regads


Hi Harish,

You can use this forge component. Also OS system event OnApplicationResume lets you track when the application returns from background to foreground.

Regards,

Hi Ruben,

I have tried this MobileEvents component but it is used with the blocks i don't have any changes in the blocks i only need to perform some actions when the app comes to the foreground.

Regards

Harish

OnApplicationResume will trigger when the application comes to the Foreground state,

you can use it, why you need a plugin for this... as it is already provided.

I tried to use OnApplicationResume but when i enter into my screen every time it is calling particular action i don't what like that i need to perform only when the app coming from background to foreground.

assif_tiger wrote:

OnApplicationResume will trigger when the application comes to the Foreground state,

you can use it, why you need a plugin for this... as it is already provided.



Harish Yerra wrote:

I tried to use OnApplicationResume but when i enter into my screen every time it is calling particular action i don't what like that i need to perform only when the app coming from background to foreground.

assif_tiger wrote:

OnApplicationResume will trigger when the application comes to the Foreground state,

you can use it, why you need a plugin for this... as it is already provided.




OnApplicationResume : Action to be executed when the application is returning from background to foreground (in the home module only).

But first time when i login into my application at that time also it is asking me to perform that action because it is executing the onApplicationResume at first time also. I don't want to ask at first time i want to ask only when the user come from background to foreground.

Thanks

Harish 

Harish if the only issue you found so far is coming from the login, why don't you go around that issue?

For example checking the login date time on top of that action.

Harish Yerra wrote:

But first time when i login into my application at that time also it is asking me to perform that action because it is executing the onApplicationResume at first time also. I don't want to ask at first time i want to ask only when the user come from background to foreground.

Thanks

Harish 

You can validate this specific scenario, by checking the current screen in action


I don't want to call this OnApplicationResume at all when i am coming from the other screen i want to call OnApplicationResume only when i am coming from the other app(i.e from background to foreforund)., how to handle this in outsystems, as i am new to this outsystems i am unable to get how to handle this please guide me.


assif_tiger wrote:

Harish Yerra wrote:

But first time when i login into my application at that time also it is asking me to perform that action because it is executing the onApplicationResume at first time also. I don't want to ask at first time i want to ask only when the user come from background to foreground.

Thanks

Harish 

You can validate this specific scenario, by checking the current screen in action


Regards

Harish