appView是cordovaActivity.appVeiw DownloadListener是webkit.DownloadListener 我也在场景中使用Crosswalk。
DownloadListener dl = 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);
finish();
}
};
appView.setDownloadListener(dl);
在编译时给出错误
sample.java:###: error: cannot find symbol
[javac] appView.setDownloadListener(dl);
[javac] ^
[javac] symbol: method setDownloadListener(DownloadListener)
[javac] location: variable appView of type CordovaWebView
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error
知道如何解决此问题吗?
答案 0 :(得分:0)
试试这个:
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);
finish();
}
}
);
答案 1 :(得分:0)
此代码适用于cordova 6 +
SystemWebView wv = (SystemWebView) appView.getView();
wv.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);
finish();
}
});