Search code examples
androidxamarinmvvmcrossinternet-connection

Check whether Internet is on or off in Xamarin Android


I am working on Xamarin Android Application.Before proceed to my next fragment I want to check Internet Connection and inform user about it ? How can i implement that ?And how to refresh whole fragment after user switch-on the internet?
Any advice or suggestion will be appreciated !


Solution

  • Try this :

    NetworkStatus internetStatus = Reachability.InternetConnectionStatus();
    
    if(!Reachability.IsHostReachable("http://google.com")) {
        // Put alternative content/message here
    }
    else
    {
        // Put Internet Required Code here
    }