Why do you want to do something that looks unreliable?
Because just learned Android development, not very good control of the Android interface editing and operation, so I want to use a rush to the HTML5 version, anyway, this application is also needed from the server to obtain a large amount of data to display on the phone, that is to say: Must be networked to work properly , so think about it, anyway, to get the data online, why not directly with my relatively familiar with a bit of HTML to do this application? The province's spending time to learn the control of the Android interface, so simple: with a bad way to do an Android program launch welcome interface, the inside page is a full-screen webview, launched after the IIS server to get Web display, you can.
But then again, this is not as good as directly write a mobile version of the Web site, with the mobile phone built-in browser opened to see the line, why still have to spend a lot of trouble to get the app? Because...... This app also need to have notification bar alert function, run a background service to get the information provided on the server, so the light web version is not enough, so the birth of this strange app.
Good app put on the server, originally figure easy, apk files compressed into Zip package, to customers download, results ... No language is, a lot of customers have no decompression software on the phone, but also do not download and install the decompression software, there is no way, have to put IIS plus support apk download features, before the IIS default installation, IIS is not support apk file download, fortunately the data good check, add an apk download support is super simple, Just get it.
In addition, considering the use of the web version of the consumption of traffic must be very large, in order to save traffic, it is easy to introduce the HTML5 cache function, but this function of a key file: Cache list file, seemingly with TXT do not use the extension. Have to use that default extension (do not know the other extension line, but it seems to have to set the MIME type of the extension can only), this extension is not the support of IIS default, but also to add manually, fortunately is not complicated.
But on the internet did not find the picture instance, so the hand spare, by the way to make a record, grabbed a simple diagram, bong on, this has this article.
Such as:
APK Download Support:
Extension: . apk
MIME type:application/vnd.android.package-archive
HTML5 Cache Support :
Extension: . manifest
MIME type:text/cache-manifest
APK download Support There is nothing to say, just throw the APK file to the server, the following simple HTML5 cache some points to note:
Examples of 1.HTML5 can be cached:
C.html
<! DOCTYPE html>
stole a lazy, directly with W3school example to get: http://www.w3school.com.cn/example/html5/html5_html_manifest.htmlThis example does not know how, it seems that IIS is not set or how, anyway, I test the cache is a failure.
The files referenced in the above file are:
./mymanifest.manifest
./js/demo_time.js
./i/w3school_banner.gif
In order to test FALLBACK: So deliberately did not put./html5_html_manifest.html on the server. Following the completion of the HTML main file, here is the writing cache list file:
2. cache List File Authoring
CACHE manifest# 2014-05-22 v1.0.0cache:./i/w3school_banner.gif./js/demo_time.jsnetwork:login.aspfallback:/. /err/404.html
Above is an example of a complete cache list file, you can see not joined./html5_html_manifest.html, in order to test the effect of the last fallback, the first few tags there is nothing to say, a lot of examples and instructions on the network, Focus on the last failure when the callback page setup, where a line is a unit, a row has two elements, the first is the network normal or file is called when the page, followed by a space and the first element is separated, the second and the element is the network is not available, or the file does not exist the replacement page, the above example, The first element is replaced with a/symbol, which means that all files that are not found or inaccessible when the network is not connected are used with the following file./err/404.html Replace the display. /here is the function of a wildcard, similar to *.
3.webview settings
Of course, if your browser itself supports caching, then the following content here you do not have to look at, the above settings, your page can be successfully cached.
But I made a reference to WebView do the app, the default cache is closed, then you must set the WebView, otherwise you can not cache: here only the webview set of code snippet, detailed call WebView example online a lot of, do not do a redundant statement.
WebSettings webseting = Mwebview.getsettings (); Webseting.setjavascriptenabled (TRUE); JS Support Webseting.setsupportzoom (TRUE); Webseting.setdefaulttextencodingname ("gb2312"); Default code page Mwebview.setscrollbarstyle (view.scrollbars_outside_overlay); scroll bar mwebview.requestfocus (); The following sections are open and set for the cache. Webseting.setdomstorageenabled (TRUE); /* DOM Storage is a perfect solution if you need to store some simple data that can be solved with key/value. * Depending on the scope of action, there are session storage and local storage two, which are used for conversation-level storage (page close disappears) and localized storage (data will never expire unless actively deleted). */Webseting.setappcachemaxsize (1024*1024*8);//Set buffer size, I set the 8M String Appcachedir = this. Getapplicati Oncontext (). Getdir ("cache", Context.mode_private). GetPath (); Set Cache path Webseting.setappcachepath (appcachedir); Sets the cache path Webseting.setallowfileaccess (true); Set can access file Read file webseting.setappcacheenabled (true); Open App Cache WebsEting.setcachemode (websettings.load_default| Websettings.load_cache_else_network); Set the cache mode to update the cache according to the HTML5 cache list file and use the cache when the network is not connected.
By completing the 4 steps above (the IIS setup is a step), your app can cache the page correctly.