ali50mahmoud

webview miss network

Mar 22nd, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. if ( !isNetworkAvailable() ) { // loading offline
  2. main_webView.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK );
  3. }
  4.  
  5.  
  6.  
  7. // WebView main_webView;
  8. main_webView = (WebView) findViewById(R.id.webView);
  9. main_webView.setWebViewClient(new MyWebViewClient());
  10. main_webView.loadUrl("http://www.lialpa.org/CM3/app.html");
  11. //end of webview setup
  12.  
  13.  
  14.  
  15.  
  16. private boolean isNetworkAvailable() {
  17. ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( CONNECTIVITY_SERVICE );
  18. NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
  19. return activeNetworkInfo != null && activeNetworkInfo.isConnected();
  20. }
Add Comment
Please, Sign In to add comment