public class MainActivity extends AppCompatActivity {
String url = "https://www.pinterest.com";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, final String url) {
}
});
webView.loadUrl(url);
}
}
Web视图未加载" https://www.pinterest.com"在应用程序内,但它正在使用chrome浏览器使用intent。我试过其他网址正在工作。加载" https://www.pinterest.com"使用webview,获取如下的输出屏幕
答案 0 :(得分:4)
你试试这个:
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAllowContentAccess(true);
settings.setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.pinterest.com/");
在清单中:
android:hardwareAccelerated="true"
答案 1 :(得分:0)
在设置中将JavascriptEnabled和AllowContentAccess以及setDomStorageEnabled设置为true