I search and no find any learn for my questions please help.
my WebView
code :
webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new WebViewClient());
WebView webView = (WebView) findViewById(R.id.webView1);
initWebView(webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
webView.getSettings().setAppCachePath("/cache/");
webView.getSettings().setAppCacheEnabled(true);
webView.loadUrl("http://google.com");
webView.setWebViewClient(new WebViewClient());
Use this
ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService(Activity.CONNECTIVITY_SERVICE);
if(connectivityManager.getActiveNetworkInfo().isConnected()){
mfnWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
mfnWebView.loadUrl(url);
}
else{
mfnWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mfnWebView.loadUrl(url);
}
Mandatory permissions :- INTERNET, ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.