持續(xù)更新
- 內存泄漏
前前后后各種找方案,都不行,最終stackOverflow上找到,為webview開啟另一個進程: 在AndroidManifest.xml中設置android:process=":remote",完美解決內存泄漏問題 - 點擊回退建,回到上一個web頁面
這個方法待定,但是確實解決了我的問題。(設置兩次goBack)
@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
webView.goBack();
webView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
- html中超鏈接
在我們webview加載的html中有個pdf文件的超鏈接,ios點擊完美打開,沒做任何處理,但是Android點擊沒反應。。。。。。(爬坑中。。。。),望知道的告知下,謝謝!
解決方案:
private class MyWebViewDownLoadListener implements DownloadListener {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
String[] urlSplit = url.split("/");
fileName = urlSplit[urlSplit.length - 1];
file = new File(Environment.getExternalStorageDirectory(), fileName);
if (!file.exists())
presenter.fileDownload(url, file);
else{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
startActivity(intent);
}
}
}
webView.setDownloadListener(new MyWebViewDownLoadListener());
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.fromFile(file));startActivity(intent);
PS:就是下載下來,然后用第三方應用打開