Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8" ?>
- <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:local="clr-namespace:TBSApplication"
- x:Class="TBSApplication.MainPage">
- <ContentPage.Content>
- <ScrollView>
- <StackLayout>
- <Button x:Name="Btn" Text="Check Connectivity" Clicked="Btn_Clicked"/>
- <Label x:Name="Lbl" Text="Status"/>
- <Label x:Name="Lbl1" Text="Type:"/>
- </StackLayout>
- </ScrollView>
- </ContentPage.Content>
- </ContentPage>
- using Plugin.Connectivity;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- namespace TBSApplication
- {
- public partial class MainPage : ContentPage
- {
- public MainPage()
- {
- InitializeComponent();
- }
- private void Btn_Clicked(object sender, EventArgs e)
- {
- try
- {
- var isConnected = CrossConnectivity.Current.IsConnected;
- if (isConnected == true)
- {
- DisplayAlert("Message", "Connected", "Ok");
- }
- else
- {
- DisplayAlert("Message", "Not Connected", "Ok");
- }
- }
- catch (System.Exception ex)
- {
- DisplayAlert("Message", ex.Message, "Ok");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment