2
Answers

Custom Alert Dialog if internet connection is not available

I show custom Alert Dialog if inteernet connection is not available but I find proble so , help and Reply me on my email address soon. I wait answer.
Answers (2)
1
Anbu Mani

Anbu Mani

NA 11.1k 877.5k 7y
Hi Try this code
 
Android.Net.ConnectivityManager connectivityManager = (Android.Net.ConnectivityManager)GetSystemService(ConnectivityService);
Android.Net.NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo;
bool isOnline = (activeConnection != null) && activeConnection.IsConnected;
if (isOnline == false)
{
var errorMessage = "Network Connection Failed";
Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
builder.SetTitle("Result");
builder.SetMessage(errorMessage);
builder.SetCancelable(false);
builder.SetNegativeButton("OK", (EventHandler)null);
builder.Show();

0
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 7y
You can implement in javascript :
 
https://www.kirupa.com/html5/check_if_internet_connection_exists_in_javascript.htm
 
or in C#
 
http://stackoverflow.com/questions/20309158/c-sharp-checking-internet-connection
 
Regarding custom alert you have to implement manually.
 
https://www.w3schools.com/howto/howto_js_alert.asp
 
http://bootboxjs.com/examples.html