[
https://issues.apache.org/jira/browse/CB-6664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15626589#comment-15626589
]
Joshua Chin commented on CB-6664:
---------------------------------
This may be over 2 years late, but I want to post my answer/fix here in case
someone else is looking for this.
Modify the plugin to enable Application Cache / AppCache :
Ionic/Cordova.
1. In the plugin's folder, find the file "InAppBrowser.java" (My location was
/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java
2. go to line - 728
3. Add the following lines: (Copied from CB-2282)
settings.setAppCacheMaxSize(5 * 1048576);
settings.setAppCachePath(databasePath);
settings.setAppCacheEnabled(true);
the final block of code looks like this:
//Toggle whether this is enabled or not!
Bundle appSettings =
cordova.getActivity().getIntent().getExtras();
boolean enableDatabase = appSettings == null ? true :
appSettings.getBoolean("InAppBrowserStorageEnabled", true);
if (enableDatabase) {
String databasePath =
cordova.getActivity().getApplicationContext().getDir("inAppBrowserDB",
Context.MODE_PRIVATE).getPath();
settings.setDatabasePath(databasePath);
settings.setAppCacheMaxSize(5 * 1048576);
settings.setAppCachePath(databasePath);
settings.setAppCacheEnabled(true);
settings.setDatabaseEnabled(true);
}
4. Save.
5. if you have already added the platform, android, remove it (ionic platform
rm android)
6. ionic platform add android
7. ionic build android
After this, my app was able to handle sites with AppCache in the InAppBrowser.
you can check by hooking up to chrome://inspect and viewing the console of the
new browser. Should say something regarding Application Cache.
Disclaimer: This may not be the best or supported method, but it passes. I have
not tested any other method, this is just the first one that worked. Feel free
to suggest a clean method.
Thanks!
-Josh
> Android/Cordova inAppBrowser doesn't use application cache
> ----------------------------------------------------------
>
> Key: CB-6664
> URL: https://issues.apache.org/jira/browse/CB-6664
> Project: Apache Cordova
> Issue Type: New Feature
> Components: CordovaLib
> Affects Versions: 3.4.0
> Environment: Android 4.4.2
> Reporter: Nick Redding
> Labels: inappbrowser,, webview
>
> I'm using the latest Cordova platform which has a supposed fix (CB-2282) to
> enable AppCache, but it doesn't seem to work on Android 4.4.2. This simple
> test illustrates (this is the startup javascript for the app):
> {code:title=index.js|borderStyle=solid}
> var app = {
> // Application Constructor
> initialize: function() {
> this.bindEvents();
> },
> bindEvents: function() {
> document.addEventListener('deviceready', this.onDeviceReady, false);
> },
> onDeviceReady: function() {
> app.receivedEvent();
> },
> receivedEvent: function(id) {
> var url = 'http://html5demos.com/offlineapp';
> var ref = window.open(url,'_blank',
>
> 'location=no,hidden=yes,toolbar=no,enableViewportScale=yes,transitionstyle=crossdissolve');
> ref.addEventListener('loadstop', function(event) {
> ref.show();
> });
> }
> };
> {code}
> The example page html5demos/offlineapp clearly shows app caching in effect
> when run from the Chrome browser, but this Cordova app shows no app cache in
> effect.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]