Does it work if you test on a browser on your PC ? It should work when you switch tab.
What browser do you use on your phone ?
Do you still have any error ? If yes, can you post them ?
It doesn't work when I switch tab, I'm trying to run it as a native Android app using Intel XDK to build it
And nope, no errors. Code compiles perfectly fine
Do you have Chrome installed on your phone ? Can you try accessing a build directly from the browser instead of the packaged version ?
EDIT: Maybe this page can be of some help ? http://caniuse.com/#feat=pagevisibility
I needed the webkit prefix to make it work on my phone but maybe you don't ?
It seems to work on Chrome, is there a reason why it doesn't work on Firefox or on the packaged version?