0

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

知道如何解决这个问题吗?

4

2 回答 2

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();
  }
}
);
于 2015-01-09T22:44:54.780 回答
0

此代码适用于科尔多瓦 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();
    }
});
于 2017-12-05T09:20:42.650 回答