HTML5 Offline app on Android devices - android

This is regarding HTML5 offline apps on Android devices.
We are running into an issue where bookmarking an offline capable HTML5 app (with a complete cache manifest file) fails to load on the Android browser under the following conditions:
Bookmark the app on the browser
Switch off all wireless connectivity
Close the browser completely
Attempt to launch the bookmark from the homescreen
We end up with an "Unable to connect to the internet" message. The app works perfectly fine on iOS devices when saved to homescreen and on airplane mode.
Is there a specific way the app should be saved, or is this an Android specific quirk?

I'd check and see that:
MIME type really is text/cache-manifest.
Your cache-manifest starts with CACHE MANIFEST, your urls thereafter are either relative to the manifest or absolute URLs.
You don't have any broken links in your manifest, or a forced NETWORK: tag.

So, I had faced similar issues with chrome and android on multiple instances. Apparently there is no issue with the implementation because I tried it on FF and it worked just fine, and the same was true about safari. The only thing I presume this is caused by is, the data is getting cache for the web page on the RAM when chrome is running. If you close the browser, and android ends the process a fresh instance of chrome is initialized and your existing app data is gone. I cannot confirm this, but it seems very likely that it might be the issue.
Also check your server is configured to send the mime type correctly: How to set up your server to send the correct MIME types

What's the file name of your cache manifest? I have heard that the extension could affect android's behavior. Make sure your file ends with .manifest
In addition, make sure your server is correctly serving the MIME type for manifest files, which is text/cache-manifest

In addition to Ben Max Rubinstein's and Compid's answer, if your app url is something like this: example.com/myapp you need to add a following forward slash, like this: example.com/myapp/.
When you are online the server will redirect you automatically, but if your are offline obviously that cannot happen.

What I encountered was that the .manifest files in Apache's mime.types configuration was correctly set to text/cache-manifest and then several lines below was overwritten as application/x-ms-application (for compatibility with MS' ClickOnce thing). To resolve this I've taken different file name ending, namely .cachemanifest, configured correctly its mime type, restarted Apache, renamed manifest file as cache.cachemanifest, changed my <html> manifest attribute to point to this file, and then I was finally able to cache my web app on Android (there wasn't any problem in desktop browsers which apparently don't care about the mime type of cache manifest file). Hope this helps.

Related

Android: allow browser to read file:///sdcard

On Android versions higher than v4.4 (since storage framework was introduced) opening the local memory filesystem in a web browser via file:///sdcard does not show all the files and folders.
For example, I can access the file:///sdcard/Download folder by typing the URL but some files and folders are not shown or some folders cannot be navigated to.
Tried with different browsers, including Firefox, Chrome, Chromium, Brave and Opera, and even though I've given all the apps the Files and media permission this is observable for all of them. Files downloaded by a specific browser would be visible from that browser, but not other files that have been placed there by other apps.
The question is how to grant full file access to /sdcard or a specific subfolder from outside the app since not all browsers mentioned above can trigger the on-demand storage permission dialog. Opera is the only which allows doing it from within the app when saving a file to a custom path — then it triggers the on-demand permission dialog and after that the chosen folder becomes fully readable through the file:// protocol.
The preferred solution would be via adb with pm or something similar.
While something like appops might allegedly be used to achieve the desired goal as per this article (didn't work for me), an easier workaround is to use the App Manager (f-droid) and enable in the App Ops tab the following permissions for your browser app:
MANAGE_EXTERNAL_STORAGE
LEGACY_STORAGE
NO_ISOLATED_STORAGE
After applying these actions for Brave, Chrome, and Chromium started displaying all files.
NOTE: Only tried on a rooted device. Since I have no unrooted devices at hand I cannot tell if this would also work on stock Android.

Suppress file already exists on android OS

is there a way to suppress on any browser in android the prompt the comes up if you are downloading a file that carries the same name as a file already on the phone
so basically i want to overwrite it , there is a chrome extensionon Pc that does that , is there something similar for android ?
Thank you
No, because the browser is its own app. It might be chrome, or firefox, or any number of others, You'd need to override it on each, and there's no API to do so, so you'd need the user to install the appropriate plugin to each (if it even exists).
Although to demonstrate the point- I have no idea what prompt you're talking about, because I've never seen it. Every browser I've ever used on Android merely downloads a new copy and places a (1), (2), etc at the end without prompting.

How to set Proxy Auto Config (PAC) file in sdcard of Android

Excuse me?
I pushed the file 'proxy.pac' to sdcard using this command:
adb push C:\Users\zuokang.li\Documents\proxy.pac /sdcard/
I try to set proxy auto config in android. So I set pac url "file:///sdcard/proxy.pac".But it cannot work.
I don't know whether it is set right. Can you help me ? Thanks!
Apparently Android doesn’t accept setting a local PAC file (127.0.0.1 doesn't seem to work either) and may even cause browser crashes for an invalid proxy port (-1). Therefore either
Use http://some_host/proxy.pac and store the file on some host, or
Use Firefox for Android and the exact same settings you used above (verified) - see https://www.topbug.net/blog/2015/03/02/configure-proxy-using-pac-files-on-firefox-for-android/ for info.
I experienced the same issue with my android phone, and searching for a solution I noted that the only one is to access to a web server for getting the .pac file (as Roy explains). But I wanted the solution (all about this) locally in my phone.
I installed a thin web server in my phone called SimpleHttpServer from Google Play and proceed as you do to set the .pac file using the URL provided by the web server (previously, I created a directory, located the .pac file inside it and pointed the web server root folder to that directory).
Additionally, I installed Simple Text Editor for .pac file edition and everything works as expected.
For use a PAC file in Android you can use Drony, looks ugly, but works! Even if you need authentication.
https://play.google.com/store/apps/details?id=org.sandroproxy.drony
Since file:/// is disabled on Android, you can convert the pac file to base64 and use this format:
data:application/x-ns-proxy-autoconfig;base64,

Android docs is very slow in ADT r20

I updated my ADT to r20. It becomes very slow to open the docs when I have internet connection. But it works well in offline mode.
It is very slow to open xxx.html in the docs directory by clicking them directly.
why? And how to fix it?
I found the problem. The url is something wrong when the html file accesses internet to download some resource files. I get these information when I access the docs' html file.
GET file://fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumi‌​talic,bold
GET file://www.google.com/jsapi/
The two are to download js files from internet, but fail to get them due to the wrong url.
How to prevent the two url accessing the internet? There are so many html files in docs, it is impossible to edit them all.
Help!

Use jQuery mobile offline

I am developing on an Android mobile system, using PhoneGap with jQuery mobile. I need my app to work without internet connection. I read the two articles from HERE and THERE, trying to import all the required files about jQuery Mobile to my Phonegap app. But it still doesn't work properly without internet.
Here are the file structure and manifest cache, I do also include the JavaScript and CSS file:
Did I miss anything? Thanks!
I prepared a jQuery Mobile offline example. Please find detailed info how to do it here.
Are you serving up your manifest file with the correct MIME type? The manifest needs to be sent with the text/cache-manifest MIME type.
Also while I can't say for sure why you application isn't working, one thing to keep in mind is that in a phonegap application the initial page is served up from the filesystem so if you have all your pages bundled together in your phonegap application you shouldn't a manifest file to make it offline.
you also need to specify network and fallback(optional) as follows :
Line starting with # are comment
# (*) online whitelist wildcard flag
NETWORK:
*
#This is optional
#FALLBACK:
#/ /offline.php

Categories

Resources