在inAppBrowser – Phonegap / Cordova中启用下载

我正在使用cordova3.5-0.26&inAppBrowser 0.5.0

现在我正在inAppBrowser中加载一个外部页面。 有一个下载button。 当我按下下载它什么都不做。 我的下载是在inAppBrowser。 正如cordova的观点。

然后我尝试使用以下代码激活下载pipe理器(对于Android)

appView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); 

这不适用于inAppBrowser。

1)如何在inAppBrowser中启用下载? 2)有什么方法可以用默认的下载pipe理器来捕捉下载? 3)如果可能请为ios和android提供解决scheme。 如果不是Android将现在做。 请帮忙…

InAppBrowser不允许下载。 您将需要修改插件以允许下载。

对于android platforms\android\src\org\apache\cordova\inappbrowser

方法名称private void navigate(String url) {

包括

 this.inAppWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); cordova.getActivity().startActivity(i); } }); 

在这行之前this.inAppWebView.requestFocus();

再次相同的代码在方法public void run() {

在这段之后

 if (clearAllCache) { CookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { CookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); 

在onCreate中的.java文件中

 appView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); 

不了解iOS