problem:
webView.setWebViewClient(new MyWebViewClient());
private class MyWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView webView, String s, Bitmap bitmap) {
super.onPageStarted(webView, s, bitmap);
showLoadingDialog(mContext, getString(R.string.loading));
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
closeLoadingDialog(mContext);
}
}
In onPageStarted in showloading, but not always perform onPageFinished, loading can not be closed, after some trial and error, to find a solution;
I thought this was webview android 5.0 above problem can not load http and https mixed content, so this made the appropriate treatment, see the problem solving webview android 5.0 can not load http and https mixed content
Set up
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webView.getSettings().setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
However there is no effect, and also to explore a lot, and finally solve the problem:
webView.setPictureListener(new MyPictureListener());
class MyPictureListener implements PictureListener {
@Override
public void onNewPicture(WebView view, Picture arg1) {
closeLoadingDialog(TeacherHomePageActivityWeb.this);
}
}