Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting re-open of an Android Chrome HTML Webapp

Recent versions of Chrome on Android have added the ability to create full screen Webapps using the 'mobile-web-app-capable' meta tag in much the same way that you can on iOS.

On iOS when you quit a web app and open it again it will always be refreshed; on Chrome it will be up to the operating system resources; and if you re-open the same web app it will often restore the previous app context without reloading the page.

This is causing problems for my Weather Web App as on re-open it often displays old forecast data which can be days out of date.

Is there a way to detect the page re-open so that I can refresh/reload the content?

like image 755
Unstableair Avatar asked Dec 05 '25 14:12

Unstableair


1 Answers

It seems that the trick is to use timers. Usually, when a webapp is in the background (not a tab background) it's frozen, so it's not executing code. Therefore, if you have a javascript timer that executes every X seconds and on one execution you see that the time passed between executions is far greater then it means that you need to update your data.

like image 139
Unstableair Avatar answered Dec 08 '25 06:12

Unstableair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!