Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1395
  • Last Modified:

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?
0
RXGeorge
Asked:
RXGeorge
  • 3
  • 3
  • 2
2 Solutions
 
GaryCommented:
Possibly not supported, alternative is js

setInterval("location.reload(true)", 60000);
0
 
RobOwner (Aidellio)Commented:
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.
0
 
RXGeorgeAuthor Commented:
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GaryCommented:
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.
0
 
RobOwner (Aidellio)Commented:
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?
0
 
RobOwner (Aidellio)Commented:
Ok, full points to Gary on this one as he seems to be on the money

When the phone is asleep the browser cannot do anything so it will not be refreshed until the user unlocks the phone.  How long does it take to refresh?  

I've tested and proved that Gary's solution of setInterval will trigger the moment the phone is unlocked.  The timeout is suspended while the phone is asleep but will start again as soon as the phone is unlocked.  It will NOT refresh while the phone is sleeping so I ask again, how long does it take to refresh and is it suitable that it will do it as soon as the phone is unlocked?

http://jsbin.com/bajev/1/edit  <=== tested on my Android phone.
0
 
RXGeorgeAuthor Commented:
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.
0
 
RXGeorgeAuthor Commented:
Sorry all, i inadvertently awarded the wrong answer... i am having the moderator help me set it to Gary's.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now