I have WebView screen with license. And everything worked perfectly until users notified me that nothing shows on Android 7+ devices.
public class DefaultWebActivity extends AppCompatActivity {
WebView mWebView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.default_web);
mWebView = (WebView) findViewById(R.id.web_view);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.w("WebActivity", "Error loading page " + description);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return true;
}
});
mWebView.loadUrl("https://google.com/");
}
@Override
protected void onPause() {
super.onPause();
mWebView.onPause();
}
@Override
protected void onResume() {
super.onResume();
mWebView.onResume();
}
}
I can see that it loads something(google url appears in shouldOverrideUrlLoading method) but it shows nothing. No error logs appear.
This code perfectly works on <7.0 android version devices. I have read that Android 7+ uses Chrome to render screen but I didn't fount what I have to add to fix issue.
Thanks in advance!
You might often face issues in updating the chrome and Android System Webview. To fix this problem, you can reboot your device, check your internet connection, stop auto-updating all apps, clear Google Playstore cache, and storage, leave the beta testing program, and manually update Android WebView app from Playstore.
Flyperlink is a great alternative app to System WebView. System WebView is the browser that is used when you open a link from within an app. It's a very basic version of Chrome that many people get very frustrated with. There are no customization options for System WebView.
Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.
Beginning October 5, 2021, Facebook Login will no longer support using Android embedded browsers (WebViews) for logging in users.
From Android doc
This is pre Android N
@Deprecated
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
This is since Android N
- @return True if the host application wants to leave the current WebView
- and handle the url itself, otherwise return false.
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return true;
}
This method is from Android N , so for this reason you have this issue only in Android N. Returning false you should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With