通過這樣的創建自己的canGoBack ....
Initally you need add the home page..
ArrayList<String> urls = new ArrayList<>();
urls.add(www.google.com);
//after that you need override this method
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
Log.d(TAG, "shouldOverrideUrlLoading: "+url);
urls.add(url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
pDialog.show();
}
@Override
public void onPageFinished(WebView view, final String url) {
pDialog.dismiss();
}
});
//for onBackPressed, same like in custom button for back click option
@Override
public void onBackPressed() {
if(!canGoBack()
{
super.onBackPressed();
}
}
//Custome Method
public boolean canGoBack()
{
if(urls.size() == 1) // home page
{
return false;
}
else
{
webView.loadUrl(urls.get(urls.size()-2)); // load previous url
urls.remove(urls.size()-1); // remove last loaded url
return true;
}
}
我也注意到這一點。查看[Chromium BUG 794020](https://bugs.chromium.org/p/chromium/issues/detail?id=794020)以及[stackoverflow question 47771494](https://stackoverflow.com/questions/47771494) 。 – hQuse
確切地說,希望他們能夠在更新中儘快修復它。 –