Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Acr.Xamarin.Forms Network connection check

$
0
0

Hi everybody,

How can i check network connection? I found sample on github but its wrote mvvm pattern.

I wrote this code but. I've got object null exception.

My sample code is:

` private INetworkService _network { get; set; }

public WebAppPage(string targetUrl,string title)
    {

        Title = title;

         // NavigationPage.SetHasNavigationBar(this, false);

        ToolbarItems.Add(new ToolbarItem("Refresh","refresh.png", () =>
        {
            var reached = false;

            reached = await _network.IsHostReachable("www.google.com");

            if (!reached)
            {
            /  var result = await this.DisplayAlert("Sorry", "Check net connection", "Ok","");



                return;
            }

           /  Debug.WriteLine("success: {0}", result);



        })); `

Is anyone help me?

Thanks.


Viewing all articles
Browse latest Browse all 58056

Trending Articles