no internet connection xml file Check internet connection Android Coding
![]() |
no internet connection xml file Check internet connection Android Coding |
no internet connection xml file Check internet connection Android Coding
Code Example:
WebView1 = ((WebView) findViewById(R.id.WebView1));
WebView1.setWebViewClient(new WebViewClient());
WebSettings webSettings = WebView1.getSettings();
webSettings.setJavaScriptEnabled(true);
ConnectivityManager connectivityManager = (ConnectivityManager)
getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if(networkInfo == null || !networkInfo.isConnected() || !networkInfo.isAvailable()){
Toast.makeText(getApplicationContext(),"no Net",Toast.LENGTH_LONG).show();
//Initialize dialog
Dialog dialog = new Dialog(this);
//Ste Content view
dialog.setContentView(R.layout.alert_dialog);
//Ste outside touch
dialog.setCanceledOnTouchOutside(false);
//Ste dialog wideh and height
dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT);
//Ste transparent background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//Ste animation
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
// Show dialog
dialog.show();
}else{
WebView1.loadUrl("https://dfgdfgdfg.php");
}
HOME
Post a Comment