Webview 无法在 Oreo 上加载
Web view desn't load on Oreo
Oreo 中无法加载 Web 视图内容 android。它不断加载然后显示白屏可能是什么问题?
`WebView mwebView = (WebView) findViewById(R.id.myWebView);
WebSettings webSettings = mwebView.getSettings();
webSettings.setJavaScriptEnabled(true);
//improve webView performance
mwebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
mwebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mwebView.getSettings().setAppCacheEnabled(true);
mwebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webSettings.setDomStorageEnabled(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setUseWideViewPort(true);
webSettings.setSavePassword(true);
webSettings.setSaveFormData(true);
webSettings.setEnableSmoothTransition(true);
mwebView.loadUrl("http://google.com");
// mwebView.loadUrl("http://invol.co/aff_m?offer_id=699&aff_id=2189&source=deeplink_generator&url=http%3A%2F%2Fwww.motherhood.com.my%2F&aff_sub=LKQ2IVP4&aff_sub2=CHINTHAKA &aff_sub3=BO3DH1NY");
//force links open in webview only
mwebView.setWebViewClient(new MyWebviewClient());`
也试试这些选项:
webSettings.setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
}
Android Oreo 使用 chrome webview 而非原生系统 webview https://support.google.com/work/android/answer/7506908?hl=en, 检查您的设备是否启用 google chrome
Oreo 中无法加载 Web 视图内容 android。它不断加载然后显示白屏可能是什么问题?
`WebView mwebView = (WebView) findViewById(R.id.myWebView);
WebSettings webSettings = mwebView.getSettings();
webSettings.setJavaScriptEnabled(true);
//improve webView performance
mwebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
mwebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mwebView.getSettings().setAppCacheEnabled(true);
mwebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webSettings.setDomStorageEnabled(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setUseWideViewPort(true);
webSettings.setSavePassword(true);
webSettings.setSaveFormData(true);
webSettings.setEnableSmoothTransition(true);
mwebView.loadUrl("http://google.com");
// mwebView.loadUrl("http://invol.co/aff_m?offer_id=699&aff_id=2189&source=deeplink_generator&url=http%3A%2F%2Fwww.motherhood.com.my%2F&aff_sub=LKQ2IVP4&aff_sub2=CHINTHAKA &aff_sub3=BO3DH1NY");
//force links open in webview only
mwebView.setWebViewClient(new MyWebviewClient());`
也试试这些选项:
webSettings.setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
}
Android Oreo 使用 chrome webview 而非原生系统 webview https://support.google.com/work/android/answer/7506908?hl=en, 检查您的设备是否启用 google chrome