My tablet Android version is 7.0 and Chrome version 62.0.3202.84.
When first run my webview app, debug window show
Didn\'t find class \"andro
There is a problem with Android after 7.0, but I managed to find a solution. For me it worked to follow this tutorial. In a summary the fragment should look like this:
public class WebFragment1 extends Fragment{
public WebFragment1() {
// Required empty public constructor
}
WebView wvPage1;
String url = "http://apptimist.studio";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_web_fragment1, container, false);
wvPage1 = (WebView)v.findViewById(R.id.wvPage1);
wvPage1.loadUrl(url);
WebSettings settings = wvPage1.getSettings();
settings.setJavaScriptEnabled(true);
wvPage1.setWebViewClient(new MyWebViewClient());
return v;
}
private class MyWebViewClient extends WebViewClient{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Uri uri = Uri.parse(url);
return true;
}
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
view.loadUrl(request.getUrl().toString());
return true;
}
}
I tried without those two lines, but it was not working, so I included them and it worked. Pay attention to add them
WebSettings settings = wvPage1.getSettings();
settings.setJavaScriptEnabled(true);
There is the notification that there might be a vulnerability to XSS attacks, you should be opening trusted websites preferably.
And here is the layout:
Hope that this will help someone as I spent a lot of time looking for the solution