Enable Download In Inappbrowser - Phonegap / Cordova
I'm using cordova 3.5-0.26 & inAppBrowser 0.5.0 Now I'm loading an external page in inAppBrowser. There is a download button. When I press the download it doesn't do anything.
Solution 1:
InAppBrowser doesn't allow download. You will need to modify plugin to allow it for downloading.
For android, inside platforms\android\src\org\apache\cordova\inappbrowser
method name private void navigate(String url) {
include
this.inAppWebView.setDownloadListener(newDownloadListener() {
publicvoidonDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = newIntent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
cordova.getActivity().startActivity(i);
}
});
before this line this.inAppWebView.requestFocus();
again same code in the method public void run() {
after this segment
if (clearAllCache) {
CookieManager.getInstance().removeAllCookie();
} else if (clearSessionCache) {
CookieManager.getInstance().removeSessionCookie();
}
inAppWebView.loadUrl(url);
in your .java file inside onCreate
appView.setDownloadListener(newDownloadListener() {
publicvoidonDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = newIntent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Don't know about iOS
Post a Comment for "Enable Download In Inappbrowser - Phonegap / Cordova"