2
Something has changed in the implementation of Webview, Webviewclient for android 7?
I have some html files in a subfolder inside the Assets folder. The file html list., which contains other links that call other html files that are in the same folder, is displayed normally but when I click on the links to call the other html files are not being displayed in Webview.
I tested on android 4 and 6 and works perfectly, on android 7 does not work.
Follows ocode:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
myWebView = (WebView) findViewById(R.id.webViewHelp);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
myWebView.setWebViewClient(new ActivityHelp.myWebClient());
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setDisplayZoomControls(false);
myWebView.getSettings().setSupportZoom(true);
myWebView.loadUrl("file:///android_asset/help/lista.html");
}
public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
super.shouldOverrideUrlLoading(view, request);
progressBar.setVisibility(View.VISIBLE);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(View.INVISIBLE);
}
}
I tested your code and got no error. Enter which
compileSdkVersion
andtargetSdkVersion
.– ramaral
@ramaral, The code does not even present error, as described in the post, I have a subfolder inside the Assets in which are the html files. webview loads the html file html list. normally, but if I click on a link contained in that file to call another file in the same folder (help) the file is not loaded in webview. On android 4 and 6 in which I did the tests works perfectly, but on android 7 simply does not load.
– Henqsan
You don’t give that information on the question. Edit it and put it there.
– ramaral
@ramaral, I edited the question.
– Henqsan
@ramaral, just to supplement the question and answer your questions, I am using compileSdkVersion 25 and targetSdkVersion 25
– Henqsan