Ttitanium webview and HTML5 application cache - android

I am using Titanium to create a application for Android. The app uses webview to load external HTML5 webpages. The webpage uses a manifest to cache the page and some assets. This works fine on desktop browsers and third party app browsers in Android (Chrome).
When I view the page in a webview in the Titanium build app, it seems that the manifest is not used, the page just loads everything from the server. The same problem occurs when I use the build in browser of my phone (HTC one X).
What I am trying to accomplish is that the pages are offline available, so that internet is not required tot view cached pages. Is there a fix for this problem, or should I go look in another direction to solve my problem?
the manifest file:
CACHE MANIFEST
# version 1
leerlingen.html
jquery.js
style.css
handler.js
NETWORK:
*

First: Titanium provides much more than a WebView. If you planned to display only web pages you maybe should have a look at PhoneGap / Cordova which might fit your needs in a better way.
As you've noticed not all browsers support HTML5 Caching feature as expected. I can't say if it doesn't work for Android in general or only for your specific version because WebKit usually does support it but it depends of the used WebKit version. And this could be different.
EDIT: It seems that (in native android) this feature can be enabled as written here: Application cache in HTML5 doesn't work in Android PhoneGap application. This is currently not possible in Titanium (there might be inofficial tweaks i don't know but from http://docs.appcelerator.com this is not possible).
Personally i'd prefer another solution. Cache data by myself and display it if there is no network connection. But this depends on what you try to achieve. Having few content which doesn't change often this would make sense. Having dynamically changing data (like twitter stream for instance) this would be difficult. Also it depends on your users and where they want to access your app.
And there is an open question: When you want to use all the caching features why do you want to create an app? Creating a simple mobile webpage would do the same job. When creating an app i wouldn't use the Caching Features of HTML 5. You should keep all the static resources in your app and simply load data from the network. This can be achieved by both Titanium and PhoneGap / Cordova. Titanium is more useful for a native UI and some native Features while PhoneGap / Cordova would be more appropriate for HTML5 based layout.

Just in case someone else is running in the same problems that i was facing, here is what i've done. HTML5's application cache does not seem to work in the build-in browser of Android and with that the webviews. In Titanium there seems to be no way to control the webview as to enable the application cache.
The work around for me was to use Titanium and it's httpClient function (Titanium.Network.HTTPClient) to request the files (HTML, CSS, javascript) and store it in the local app filesystem (Titanium.Filesystem).

Related

Using Chrome component as WebView app container

I have issue: in standard browser on some Android 4.2-4.4 devices my html page in some reasons (which I don't understand yet) looks broken as like as part of css just lost. But in Chrome app they are always looks good. So is there option to use Chrome app as main container for my webview application?
So is there option to use Chrome app as main container for my webview application?
WebView is using Chromium on Android 4.4+.
You cannot embed Chrome in your app, other than to the extent that WebView does.
IIRC, there are third-party libraries for embedding alternative Web rendering engines in an app. I seem to recall there being a standalone Chromium build, and Mozilla was working on allowing Gecko to be used as a library. I have not checked on the status of these in quite some time. You would also then be responsible for security updates for those Web rendering engines, and the libraries may substantially increase the size of your app.

A web based phone app with online and local html files

Hello i am working on a mobile magento theme. What i am looking is to embed or either cache the html, css and javascript files (do not know which is better!) to the application (local storage on phone) and retrieve the product catalog and related pictures from the database and online servers
My intention is to make the app have minimum load on startup and shows as normal native apps
Can you give some guidelines and routine to do so .
Thanks you.
You can either give PhoneGap a shot (http://www.phonegap.com), or try it yourself, since PhoneGap is nothing more than some small libraries to make native function (notifications, vibrating etc.) available for JavaScript calls.
If you just want to wrap your site into a native app, you can just put it inside a WebView, which runs exactly like the native Android browser.
If you want to use your html, css and js files to create an android app then the easiest way to attempt this is http://phonegap.com/
However, I would strongly urge you to build a native app (on Android) as Phonegap comes with tons of problems and less support.

Accessing device native features in cordova webview

I am making a Hybrid Application using cordova-cli. My requirement is that the first page in my application must redirect to a website. The entire data required for the application will be loaded into this website from some other data-sources.
The requirement is to access device native features such as camera, accelerometer etc. from pages on this website.
I am using
location.href="http://www.example.com";
to open the pages. I need a unified cordova.js file with all the plugins embedded into it.
Currently I am putting the individual plugins into the lib\android\plugin\android and by using the grunt -f command from grunt-cli, the cordova.js file recieved for android does not seem to produce expected results.
Can't be done I am afraid - because of the way Cordova interacts with the device.
What happens if, using a non-mobile device, you accessed the same website from elsewhere? The website will not know what on earth Cordova is.
Cordova interacts with the native code on the device, so requires this to handle the passing of JS-to-native, and vice-versa.

Convert Mobile Web into Native Apllication Using WebView/phoneGap

I am gonna develop a mobile application for multiple devices, say iPhone, iPad and Android Devices like Samsung Galaxy, Samsung Tab and Samsung Galaxy Nexus,
The application is about listing set of information from webservice to list in the application, So I decided to go for Mobile Web app using jquery mobile,
I want to publish the app in Appstore and Android Market, So I want to wrap the Mobile web in to a Native app, I thought an idea of implementing it in a UIWebView in iOS and WebView in Android,
Another option I found out is phoneGap,which provide an SDk to wrap an Web app into a Native iOS or Android App.
Can you people suggest me , Is it better to go with WebView in your native application, or is it really required to use phoneGap, Whether apple will approve my Application if I am using Mobile Web app in a UIWebView, Kindly Suggest.
Note: In my application there is no real need of Using any native functionality of iOS like, Camera, Contacts etc, I just wanna have a list with information fetched from the Webservice.
If you don't need any of the native features phonegap/callback gives you, do not use it. It's a bloated project that will probably add a ton of features you don't need, if you only need a wrapped web application.
Just use a regular webview, enable JS, caching etc and load your HTML into it.
Use phonegap. http://phonegap.com/
If u use it you can use the phonegap build service to generate apps for all platforms via it. you will only have to worry about the js, html part of the app, like you said.
Or if you dont want to use the phonegap build, still creating your own apps with phonegap is way easier as you dont have to write ANY native code.
There were some issues in Phonegap before because of which Apple was rejecting Phonegap apps previously. Thats fixed now, so thats no problem. :)

Accessing the currently displayed website of the Android browser

is it possible to programmatically access the website that is currently displayed within the Android browser?
As far as I know the native Browser doesn't handle plugins (please correct me if I'm wrong), so I thought that reading the browser cache would be an option.
Is there a more sophisticated way to get the currently displayed HTML?
Thanks in advance!
S.
is it possible to programmatically access the website that is currently displayed within the Android browser?
That would be a security violation, so, no. Also bear in mind that there are several Web browsers for Android.
As far as I know the native Browser doesn't handle plugins (please correct me if I'm wrong)
The standard browser app supports plugins, but not ones downloaded on the fly. So, for example, it supports the Flash plugin (on Android 2.2+), but you have to install Flash separately first.

Categories

Resources