Link to home
Start Free TrialLog in
Avatar of RXGeorge
RXGeorge

asked on

HTML5 Meta Refresh Not Working for Android

I have a web app that needs to run on mobile phones.  I cannot get the page to refresh using the meta tag.   This is the code that I am using:

<meta http-equiv="refresh" content="600">

But the refresh never occurs on Android KitKat's Chrome browser.  Obviously, the app is inactive for some time when the phone sleeps.  But when you awaken the phone and switch to the web page - it does not ever refresh.

Any pointers?
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Test this in your browser as it works for me.  http://jsbin.com/wuhesu/1

I'm running Android 4.3 on 2 devices and the refresh works.  What version of Chrome are you using? (Go to Menu, Help & Feedback when in the browser)

Chrome is not specific to KitKat but is built to run on any version 4.0 and up.
Avatar of RXGeorge
RXGeorge

ASKER

The problem is that when the moment to refresh arrives, if the phone is asleep - it gets skipped until the next one arrives.  

10:00 page loads and refresh set to 10 minutes.  User reads it and puts the phone to "sleep".
10:10 phone is asleep so this refresh will never happen
10:11 user wakes phone and looks at page and its unchanged (no refresh), User reads it and puts back to sleep.
10:20 phone is asleep so this refresh will never happen
10:25 user wakes the phone and looks at page and its unchanged (no refresh). User reads and puts back to sleep.
etc..
etc..
etc..

The user needs to have the phone active at one of the set intervals in order to have the refresh take place.

I would like to see the refresh occur after returning from sleep/power-off assuming at least one interval has passed.  

The demo you gave me seems to work - but because you have such a short interval, i cannot tell if the refresh would occur cumulatively - where the total amount of accumulated real time exceeds the interval.
Well I looked for a reason behind it and couldn't find any.
What I can tell you is that the javascript solution above would fire, all suspended js actions (reload) are executed when the phone wakes.
I guess as the meta refresh is an internal timer then it is reset when the phone sleeps - this is just a guess as I am not sure.
I would suggest using phonegap to convert your web app to a native application that can run on android.  When sleeping the phone it will suspend the browser and all things that go with it.  With an app you can specify to prevent the phone from sleeping or detect when your app is active again (and will do a refresh).  Is that an option?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Rob, Thanks Gary.  

The refresh is quite fast.  Assuming  that the phone does have network access when its awakened... then yes that would be suitable.
Sorry all, i inadvertently awarded the wrong answer... i am having the moderator help me set it to Gary's.